beast
beast copied to clipboard
Robust HTTP Server Example
It would be nice to have a new example HTTP server that supports POST to upload files, GET / to see the list of files, and GET
I am currently working on that... Not that anybody should necessarily wait for that. My experience working with beast is very limited at the moment.
The current code (on my end) is based on C++20 (could be easily down-graded to C++17). Does this even make for a useful example for you guys?
Personally I think there is great value in a c++20 example. @vinniefalco I presume we'll also want to implement a c++11 version?
You have to use your best judgement. Try to follow the existing examples in terms of style. A C++20 example is okay (I assume because you want to use co_await). But in that case you also need a regular async/callback port of it. We can leave out the synchronous version :)
Here is my "example" on how to use boost.beast: https://github.com/Tectu/malloy
I might have digressed a bit.
Maybe it's still worth listing it somewhere?
This is so far mainly the grunt work. It has many rough edges and needs serious improvements in several places.
I'd be thankful for any kind of feedback (or direct contributions!)
The "example" has been released as v0.1.0: https://github.com/Tectu/malloy
Current feature list:
- High-level controller to setup I/O context, SSL context, worker threads and more
- HTTP
- Plain or TLS (SSL) connections
- Cookies
- Sessions
- Upgrading connections to WebSocket
- Client
- Response filters
- Server
- Routing
- Simple handlers (useful for building REST APIs)
- Target matching via regex
- Capturing groups via regex
- Sub-routers (nested/chained routers)
- Redirections
- File serving locations
- Preflight responses
- Access policies
- HTTP basic auth
- Custom access policies
- Websocket endpoints (with auto-upgrade from HTTP)
- Simple handlers (useful for building REST APIs)
- Request filters
- Routing
- WebSocket
- Client
- Server
- Connections upgradable from HTTP
- HTML
- Forms
- Supported encoding types
application/x-www-form-urlencodedmultipart/form-datatext/plain
- Parsing
- Rendering
- Supported encoding types
- Forms
Feedback and contributions are highly welcomed.
This is BIG !!
This is more like a framework than an example
This is more like a framework than an example
Hence I wrote "example" in quotation marks :p
No but seriously. This honestly started off as an example - I kid you not. I had several application using beast and a lot of the stuff was being repeated between applications. Putting this into a library/framework made sense (to me).
I will keep push this forward. I think that a fair share of beast users are dealing with lower level stuff they don't necessarily want to deal with but have to. I hope that this library will ease the pain and provide developers looking for a higher-level solution with a solid base built on top of beast.
You can definitely help out with a star ;p
I was so caught up looking at the wonderful work you've gone that I forgot to Star, Like and smash that Subscribe button
Haha ^^
So, do you think this is useful to you and other beast users? Should we point people towards this as an option for those who'd like to avoid the lower level stuff?
I’d like to write a little application with it to give you some feedback.
Please do - that would be highly appreciated.
New release is available: https://github.com/Tectu/malloy/releases/tag/0.3.0
Seems like we're on the right track here, guys! Some feedback from a user & awesome contributor of malloy:
Serving a file with load balanced across multiple threads and asynchronous in less than 50 lines is damn impressive (its one of the reasons I started using and contributing to malloy, the router and client interfaces are really nice well done :p)
I think this approach of boost.beast being low level and malloy being higher level is gonna work out in everyone's favor!
As such: Please keep up the good work guys!
Wonderful.
@Tectu any progress to report?
@Tectu any progress to report?
Yeah, lots of progress to report - anything specific you're interested in? I didn't report back here on each release as I didn't want to spam - but library developments are going well :)
The next release of malloy (0.6.0) is expected to land in the next few days.
And probably most importantly: By now, malloy is being used successfully in a couple of real-world programs/software.
There is also ongoing work for providing some higher-level interface to create REST APIs in the feature/rest branch. Hopefully, GraphQL will follow in the future as well. Of course, all of these things are optional to keep the core library as lean as possible.
Malloy is now also available as a package on FreeBSD. If somebody feels like creating packages for other operating systems (such as Ubuntu, Fedora, Arch, MacOS ...) that would be great :)