v3.0.0-alpha.1
Pre-release
Pre-release
·
98 commits
to v3.0.0-alpha
since this release
Changelog
- The thread pool can now be resized at runtime.
Server::start_threadedhas been replaced withServer::workersto set the number of worker threads and the normalServer::start.- Supply a context to all route handlers.
The context contains a reference to the server, request, and acts as a response builder.
Note: This also allows access to the thread_pool for both executing tasks and resizing it. - Remove the
stateful_routemethod, use normal routes withctx.app()instead. - You can now send responses before the route handler ends.
This allows you to easily send a response and then do some work after the response is sent as to not block the client. - Responses can be sent from other threads.
You will have to notify the handler that you will be sending a response after the handler function returns withctx.guarantee_will_send(). - Allow returning any error type from route handlers.
This is done with a return type ofResult<(), Box<dyn Error>>. - Allow attaching extra context to an error with anyhow like functions:
context,with_context,status,with_status,header,with_header. - Remove
StartupError::NoStateerror. - Make
ForceLockMutex,ForceLockRwLock, andSingleBarrierpublic through theinternal::syncmodule.- The force lock traits are used to lock a
MutexorRwLockeven if it is poisoned. - The
SingleBarrieris used to have a thread wait until another thread unlocks the barrier.
The difference from a normal Barrier is that it does not block on both sides, only the waiting side.
- The force lock traits are used to lock a
- Replace the
TcpStreaminRequestwithSocket, a wrapper struct.
Its used to allow automatically the barrier with a response is sent.
In the future it might also be used for optional TLS support. - Move path parameters into Context and use a HashMap instead of a Vec.
- Parse the HTTP version into an enum instead of a string.
- Properly determine weather to use keep-alive or not.
In HTTP/1.1 keep-alive is opt-out, but previous versions of afire assumed it was opt-in.
Fixing this produced a 2x performance increase in the benchmarks I ran.
Now, this is still only a ~500us improvement but hey. - Filter CLRF characters from headers. This prevents a potential response splitting attack.
- Properly disallow HTTP/1.1 requests with no Host header.
- Added a new ResponseBody type of Empty.
- Added a
current_threadfunction to the threadpool. - Catch panics at the thread-pool level, not the route handler level.
This will ensure that a worker will not die, even if internal afire code panics.
What's Changed
- Fix #46 by @Basicprogrammer10 in #47
Full Changelog: v2.1.0...v3.0.0-alpha.1