wilzbach / vibe-d-by-example

Showcasing Vibe.d's features by simple examples
12 stars 1 forks source link

HTTP server example #1

Open carun opened 6 years ago

carun commented 6 years ago

Hi Seb,

Can you create examples for using vibe-d as plain HTTP server only with multiple IO threads? I'm not sure if there are enough examples out there that shows how vibe-d can be used as a pure HTTP server.

For instance, in the C++ land, cpp-netlib is the preferred HTTP server (at least for me). It offers a very clean separation between HTTP server an other layers that can be built on top of it. We can allocate a pool of IO-threads to handle the time consuming data transfer and so on. Example here

It also facilitates to upload GB's of streaming data streaming directly to memory or to file - the user is free to implement the handler in a very simple interface (ugly/complex C++ syntax though).

There are examples that shows how it's possible to combine cpp-netlib with a work queue

Thanks for creating this repo!

wilzbach commented 6 years ago

Thanks a lot for the ideas. Just an FYI: this repo is really WIP and I hardly find time to work on it, so it might take a few weeks until this is actually "usable" / contains good content. In the meantime, this is a good resource:

https://github.com/vibe-d/vibe.d/tree/master/examples

e.g.

https://github.com/vibe-d/vibe.d/blob/master/examples/tcp_separate/source/app.d https://github.com/vibe-d/vibe.d/blob/master/examples/http_server/source/app.d

It also facilitates to upload GB's of streaming data streaming directly to memory or to file - the user is free to implement the handler in a very simple interface

BTW .bodyReader is already a stream.