-
Notifications
You must be signed in to change notification settings - Fork 2.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
Nice way to call "handle_file_request" from user code #1906
Comments
@paulharris thanks for the idea. There is no need for it in any my projects for now. But a pull request is always welcome! |
@paulharris I am beginner in open source & would like to work on this. can you please explain me what needs to be done here? |
@paulharris I implemented it. (https://github.com/yhirose/cpp-httplib?tab=readme-ov-file#send-file-content) svr.Get("/content", [&](const Request &req, Response &res) {
res.set_file_content("./path/to/conent.html");
});
svr.Get("/content", [&](const Request &req, Response &res) {
res.set_file_content("./path/to/conent", "text/html");
}); |
Thanks @yhirose ! I find |
Hi, this was partially addressed in #235 ,
I think it would be nice if we could write code along the lines of:
or something similar.
The point is
Server::handle_file_request
calls find_content_type() and does the neat mmap async method now, it would be nice to simply be able to ask httplib to send a specific file when desired.favicon.ico is a simplistic example, but there are other cases where you compute a filename and want to send that.
The text was updated successfully, but these errors were encountered: