Stiffstream / restinio

Cross-platform, efficient, customizable, and robust asynchronous HTTP(S)/WebSocket server C++ library with the right balance between performance and ease of use
Other
1.15k stars 93 forks source link

How to serve files #43

Open Milerius opened 5 years ago

Milerius commented 5 years ago

In golang i simply do:

router.ServeFiles("/logs/*filepath", config.GConfig.LogsPath)

ServeFiles serves files from the given file system root. The path must end with "/filepath", files are then served from the local path /defined/root/dir/filepath. For example if root is "/etc" and *filepath is "passwd", the local file "/etc/passwd" would be served. Internally a http.FileServer is used, therefore http.NotFound is used instead of the Router's NotFound handler.

(i want to serve the logs file of my server so we can read it online)

i dont find the equivalent with restinio in the documentation :'(

eao197 commented 5 years ago

RESTinio hasn't such top-level functionality yet. You have to implement it by yourself by using sendfile functionality: https://stiffstream.com/en/docs/restinio/0.5/sendfile.html An example: https://github.com/Stiffstream/restinio/blob/master/dev/sample/sendfiles/main.cpp

Milerius commented 5 years ago

@eao197 Ah ok, it's can be great if we can have such a functionality for serving specific directory for example ! thank's for your example i will try to follow