-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
webserver hook: allow to handle external http protocol #7459
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.
Generally nice. I like the lambda work in addHook
!
It's use is a little obscure, however, and we don't have any docs for this class. Would it be possible to use the hook in an example somehow, so people can see it in action w/o using the external webDAV class?
@earlephilhower I addressed your review, I still need to check whether lambdas/functionals are in flash (not iram) thanks to your snippet
|
Example is provided in |
(void)method; | ||
(void)url; | ||
(void)client; | ||
(void)contentType; |
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.
Minor style nitpick - by omitting argument name in the signature, there would be no need for these 4 lines.
There is also [[maybe_unused]]
/ [[gnu::unused]]
for local declaration, since now we use c++17. But that one is mostly for variables
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.
Nice!
webserver.addHook()
addition, allowing to handle external http protocols on the same port, at least like WebDAV and WebSocket.Tested with ESPWebDAV branch v2.
A hook function can use URI and http method to check if it would handle the http request.
There are 4 possible return values:
Hook function is not interested
Hook function took and handled the current http request, webserver must skip it but can handle the next request
Issue with http protocol, or general malfunction, or connection is done. Connection should be closed.
The tcp connection has been given to someone else, it must not be closed neither anymore handled
(this is typically for websockets)
Example of a hook function: call on webserver, function itself.