-
Notifications
You must be signed in to change notification settings - Fork 72
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: redesign http query url #898
Conversation
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.
Looks good, just some minor refactoring suggestions
cmd/booster-http/server.go
Outdated
writeError(w, r, http.StatusBadRequest, "unsupported format") | ||
} | ||
} else { // Error if more than 1 format value | ||
writeError(w, r, http.StatusBadRequest, "unsupported query") |
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.
Let's try to give the user as much information as possible if they get the parameters wrong:
writeError(w, r, http.StatusBadRequest, "unsupported query") | |
writeError(w, r, http.StatusBadRequest, "missing 'format' query parameter") |
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.
We support no format query and default to a piece in that case. I have changed the error msg to be more detailed though.
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.
I'm not sure if I'm reading the code correctly, but it looks like it will return an error if the user doesn't specify the format
query parameter.
If the user doesn't specify the format
query parameter then len(q["format])
will be zero here, right?
if len(q["format"]) == 1
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.
My bad. Fixing it.
cmd/booster-http/server.go
Outdated
@@ -112,31 +110,31 @@ const idxPage = ` | |||
Download a raw piece by payload CID | |||
</td> | |||
<td> | |||
<a href="/payload/payloadcid">/payload/<payload cid></a> | |||
<a href="/piece?payloadCid=bafySomePayloadCid&format=piece" > /payload/<payload cid></a> |
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.
Let's also change the link target text for these:
<a href="/piece?payloadCid=bafySomePayloadCid&format=piece" > /payload/<payload cid></a> | |
<a href="/piece?payloadCid=bafySomePayloadCid&format=piece" >/piece?payloadCid=<payload cid></a> |
Fixes #888