The function decorated with serverino.config.onServerInit is called when the server is initialized, and it is
used to configure the server. It must return a serverino.config.ServerinoConfig object.
In this example, the server is configured to listen on localhost:8080, with 2 workers.
Every function decorated with serverino.config.endpoint is an endpoint. They are called in order of priority assigned with
serverino.config.priority (default is 0). The first endpoint that write something to the output is the one that will respond to the request.
The serverino.config.route attribute can be used to filter the requests that are passed to the endpoint, using a uri or a bool delegate(Request r) argument.
In this example, only requests to /hello are passed to the hello endpoint. The serverino.config.route attribute can be used multiple times to specify multiple routes also using a delegate.
Serverino is a small and ready-to-go http server, in D. It is multiplatform and compiles with DMD, LDC and GDC.
The following example shows how to create a server that responds to all requests with the request dump, in a few lines of code.
serverino.interfaces.Request is the request object received, and serverino.interfaces.Output is the output you can write to.
A more complete example is the following:
The function decorated with serverino.config.onServerInit is called when the server is initialized, and it is used to configure the server. It must return a serverino.config.ServerinoConfig object. In this example, the server is configured to listen on localhost:8080, with 2 workers.
Every function decorated with serverino.config.endpoint is an endpoint. They are called in order of priority assigned with serverino.config.priority (default is 0). The first endpoint that write something to the output is the one that will respond to the request.
The serverino.config.route attribute can be used to filter the requests that are passed to the endpoint, using a uri or a bool delegate(Request r) argument. In this example, only requests to /hello are passed to the hello endpoint. The serverino.config.route attribute can be used multiple times to specify multiple routes also using a delegate.