A http server framework for Jai that’s very much NOT DONE YET. It’s mostly a place to fool around with HTTP stuff until I have enough pieces together to turn it into a proper framework.
It aspires to become someting similar to hapi but without all the Node.js nonsense.
- When clients connect, the main server thread adds their socket to the main Wait_Group and waits for the whole header to arrive.
- Once we know we have the full header, the request gets dispatched to one of the request threads for parsing and processing.
- After parsing the request thread looks up the route for that request.
- If the route requires authentication, the server tries the next entry in server.default_auth_methods from the request thread.
- If the auth function yields on Async_Tasks, the request thread finishes work and the Async_Tasks get queued on the main Wait_Group.
- Once all async tasks finish, the request gets re-scheduled on the request threads.
- If no auth method called
proceed_request_past_authentication
and the server has exhausted all methods, it responds with .UNAUTHORIZED. - After authentication, the main route’s request handler is called.
- If the request handler yields on Async_Tasks, the request thread finishes work and the Async_Tasks get queued on the main Wait_Group.
- Once all async tasks finish, the request gets re-scheduled on the request threads.
- Step 5 is repeated until the request handler responds or returns without yielding (which casues an automatic 500 response).
- After the response has been sent, the client gets re-queued on the main Wait_Group for subsequent requests (… if the connection is not supposed to be closed after the request).