-
Notifications
You must be signed in to change notification settings - Fork 172
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
Add RFC7231 Accept header parsing #80
Comments
Good catch @ekroon , did you mean to access the endpoint by loading it directly in a browser or loading it through AJAX call? Regardless, I agree with you that we should support q factor weighting in request header parsing. I think a fallback to json makes sense when accept header is not specified at all by the client. Otherwise, it might confuse the client. |
I mean loading it directly in the browser window. |
Got it, extending on your use-case, I think it might be an interesting idea to implement a html or xml encoding type. The html encoding could render the query result in a nicely looking web page to help better visualize the result. We can even throw in some js code to make the resulting web page interactive. |
Hi, I agree with @ekroon A fallback to application/json would be enough. Thanks!! |
A full implementation for Accept header parsing will be a bit involved as there is no implementation available for Axum. The correct place to implement this would be hyperium/headers#7 but that appears to be a little bit stalled. Maybe a port of Rocket or Actix's implementation in a separate crate is a quicker solution. Alternatively, supporting the format in the url extension, like |
Thanks @ekroon , I agree with both of your points :) For your first point, on top of what's in rocket and actix, I think we can also take hyperium/headers#70 as a reference to build out the crate. |
I would like to use ROAPI endpoints from a browser. Currently when accessing
/api/tables/{table_name}
endpoint with a browser you get an error like the following:{ "code": 400, "error": "unsupported_content_type", "message": "\"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9\" is not a supported response content type" }
How to parse the Accept header is specified in RFC7231 and Actix has an implementation for this. How to implement this would be impacted by #76 and if this would be implemented it might make switching harder.
An easy quicfix would be to implement a fallback to
application/json
if the resulting content-type is unknown.The text was updated successfully, but these errors were encountered: