-
Notifications
You must be signed in to change notification settings - Fork 5
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
base: develop
Are you sure you want to change the base?
Conversation
fa1dcad
to
35be15c
Compare
df4017b
to
35169aa
Compare
@@ -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)) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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"` |
There was a problem hiding this comment.
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).
No description provided.