v3.0.0-alpha.1
Pre-release
Pre-release
connorslade
released this
21 Aug 05:13
·
98 commits
to v3.0.0-alpha
since this release
Changelog
- The thread pool can now be resized at runtime.
Server::start_threaded
has been replaced withServer::workers
to 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_route
method, 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::NoState
error. - Make
ForceLockMutex
,ForceLockRwLock
, andSingleBarrier
public through theinternal::sync
module.- The force lock traits are used to lock a
Mutex
orRwLock
even if it is poisoned. - The
SingleBarrier
is 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
TcpStream
inRequest
withSocket
, 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_thread
function 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