Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Accept contentType params for DID URL Resolution [DEV-4722] #325

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

DaevMithran
Copy link
Contributor

No description provided.

@ankurdotb
Copy link
Contributor

@DaevMithran DaevMithran marked this pull request as draft January 31, 2025 09:21
@ankurdotb ankurdotb changed the title feat: Accept contetType params for DID URL Resolution feat: Accept contentType params for DID URL Resolution Jan 31, 2025
@ankurdotb ankurdotb changed the title feat: Accept contentType params for DID URL Resolution feat: Accept contentType params for DID URL Resolution [DEV-4722] Jan 31, 2025
@DaevMithran DaevMithran marked this pull request as ready for review February 6, 2025 10:14
@DaevMithran DaevMithran force-pushed the DEV-4722 branch 7 times, most recently from fa1dcad to 35be15c Compare February 6, 2025 13:26
@DaevMithran DaevMithran force-pushed the DEV-4722 branch 2 times, most recently from df4017b to 35169aa Compare February 6, 2025 13:36
@@ -22,6 +23,13 @@ import (
// @Failure 501 {object} types.IdentityError
// @Router /{did}/resources/{resourceId} [get]
func ResourceDataEchoHandler(c echo.Context) error {
// Get Accept header
requestedContentTypeParam := services.ExtractMediaTypeParams(c.Request().Header.Get(echo.HeaderAccept))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ExtractMediaTypeParams is not doing the q-value sorting or multiple accept headers prioritization properly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sownak can you give an example

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accept: text/xml;q=0.8, application/json;q=0.9

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DaevMithran This is in the task description :) Please follow the link on it for explanation and examples.

@@ -39,3 +39,27 @@ func PrepareQueries(c echo.Context) (rawQuery string, flag *string) {
func GetDidParam(c echo.Context) (string, error) {
return url.QueryUnescape(c.Param("did"))
}

func ExtractMediaTypeParams(mediaType string) map[string]string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understand, this is just stripping out the q values without taking it into consideration for priority order?

@@ -22,6 +23,13 @@ import (
// @Failure 501 {object} types.IdentityError
// @Router /{did}/resources/{resourceId} [get]
func ResourceDataEchoHandler(c echo.Context) error {
// Get Accept header
requestedContentTypeParam := services.ExtractMediaTypeParams(c.Request().Header.Get(echo.HeaderAccept))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DaevMithran This is in the task description :) Please follow the link on it for explanation and examples.

DIDJSONLD ContentType = "application/did+ld+json"
JSONLD ContentType = "application/ld+json"
JSON ContentType = "application/json"
W3IDDIDURL string = "https://w3id.org/did-url-dereferencing"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's two different headers/profiles but only one listed here, so I think this hasn't been accounted for at all. This is profile="https://w3id.org/did-resolution" described in the task, which is different then URL dereferencing for resources.

DereferencingMetadata DereferencingMetadata `json:"dereferencingMetadata"`
ContentStream ContentStreamI `json:"contentStream"`
Metadata ResolutionResourceMetadata `json:"contentMetadata"`
Context string `json:"@context,omitempty" example:"https://w3id.org/did-resolution/v1"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this header should only be inserted if the Accept header has some combination of LD+JSON (i.e., they have requested JSON-LD).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants