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: redesign http query url #898

Merged
merged 6 commits into from
Oct 20, 2022
Merged

feat: redesign http query url #898

merged 6 commits into from
Oct 20, 2022

Conversation

LexLuthr
Copy link
Collaborator

Fixes #888

@LexLuthr LexLuthr requested a review from dirkmc October 17, 2022 17:24
@ribasushi
Copy link
Contributor

@dirkmc @LexLuthr please make sure/test that this keeps working as expected with caching in the mix. I.e. someone calls with a range and a &format=car and then drop the format specifier: will they get different bytes as they should?

cmd/booster-http/server.go Outdated Show resolved Hide resolved
cmd/booster-http/server.go Outdated Show resolved Hide resolved
Copy link
Contributor

@dirkmc dirkmc left a 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

@LexLuthr LexLuthr requested a review from dirkmc October 18, 2022 16:30
cmd/booster-http/server.go Outdated Show resolved Hide resolved
cmd/booster-http/server.go Show resolved Hide resolved
cmd/booster-http/server.go Show resolved Hide resolved
cmd/booster-http/server.go Show resolved Hide resolved
writeError(w, r, http.StatusBadRequest, "unsupported format")
}
} else { // Error if more than 1 format value
writeError(w, r, http.StatusBadRequest, "unsupported query")
Copy link
Contributor

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:

Suggested change
writeError(w, r, http.StatusBadRequest, "unsupported query")
writeError(w, r, http.StatusBadRequest, "missing 'format' query parameter")

Copy link
Collaborator Author

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.

Copy link
Contributor

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My bad. Fixing it.

@@ -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>
Copy link
Contributor

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:

Suggested change
<a href="/piece?payloadCid=bafySomePayloadCid&format=piece" > /payload/<payload cid></a>
<a href="/piece?payloadCid=bafySomePayloadCid&format=piece" >/piece?payloadCid=<payload cid></a>

@LexLuthr LexLuthr merged commit 86bfc54 into main Oct 20, 2022
@LexLuthr LexLuthr deleted the feat/redesign-http-query-url branch October 20, 2022 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rename HTTP URL from "payload" to something else
4 participants