Crate afire[−][src]
Expand description
🔥 afire
A blazing fast dependency free web framework for Rust
💠Install
Just add the following to your Cargo.toml
:
[dependencies]
afire = "0.2.0"
📄 Info
This is kinda like express.js for rust. It is not that complicated but it still makes development of apis / servers much easier. It supports Middleware and comes with some built in for Logging and Rate limiting.
For more information on this lib check the docs here
💥 Examples
For some examples go here.
Here is a super simple examples:
// Import Lib
use afire::{Server, Method, Response, Header};
// Create Server
let mut server: Server = Server::new("localhost", 8080);
// Add a route
server.route(Method::GET, "/", |_req| {
Response::new()
.status(200)
.text("Hello World!")
.header(Header::new("Content-Type", "text/plain"))
});
// Start the server
// This is blocking
server.start().unwrap();
// Or use multi threading *experimental*
server.start_threaded(8);
🔧 Features
Here I will outline interesting features that are available in afire.
- Builtin Middleware
afire comes with some builtin extensions in the form of middleware. For these you will need to enable the feature.
To use these extra features enable them like this:
afire = { version = "0.2.0", features = ["rate_limit", "logging"] }
- Threading
Just start the server like this. This will spawn a pool of threads to handle the requests. This is currently experimental and does not support middleware…
use afire::{Server, Method, Response, Header};
let mut server: Server = Server::new("localhost", 8080);
server.start_threaded(8);
Structs
Represents a Cookie
Http header
Struct for holding query data
Http Request
Http Response
Defines a route.
Defines a server.
Represents a Client’s Cookie
Enums
Methods for a request