This is a prototype web server that can be used in no_std
environments like on embedded systems. It uses no memory allocations and should be completely infallible.
An example implementation is provided in runners/desktop
. Runners can be implemented in environments with std
and memory allocation. This will not impact the server implementation.
To implement the server:
- Create a type that implements
ServerConfig
. This will handle the incoming and outgoing messages. - Create a type that implements
Connection
. This will handle the individual requests. - Create a new instance of
Server<T, N>
whereT
is yourServerConfig
implementation andN
is the amount of concurrent connections the server should be able to handle.- Note that all connections are always allocated on the stack, so keep this number small on low power devices.
- Feed this server with:
new_connection(addr)
when a new connection comes in.client_disconnected(addr)
when a connection is disconnected.data_received(addr, &[u8])
when data is received from an address.poll_write()
when the server is ready to send data.
Licensed under either of
-
Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
-
MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.