-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
net: http_server: allow specifying a default resource #83811
base: main
Are you sure you want to change the base?
net: http_server: allow specifying a default resource #83811
Conversation
The _detail parameter of HTTP_SERVICE_DEFINE is used to optionally specify a default resource detail, which will be served if no other resource matches the URL. Signed-off-by: Matt Rodgers <[email protected]>
Should we mention about this also in the API documentation which has examples of the usage? |
Added some documentation for this change |
Add documentation showing how to use the _detail parameter when registering an HTTP service to provide a default resource handling any unknown path. Signed-off-by: Matt Rodgers <[email protected]>
94fb189
to
9f9b19b
Compare
It would be great to provide a page that can be used to communicate any HTTP status code, and Zephyr could provide one that users could choose to use. Default might not be the best terminology, but I think the idea is good. |
const struct http_request_ctx *request_ctx, | ||
struct http_response_ctx *response_ctx, void *user_data) | ||
{ | ||
static const char response_404[] = "Oops, page not found!"; |
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.
Is it possible to reuse this in a more generic way for any HTTP error?
The
_detail
parameter ofHTTP_SERVICE_DEFINE
is currently unused - use this to allow specifying a default resource detail which will be served if no other resource is matched. If the parameter isNULL
, the existing behaviour is retained.This could be used to: