Expand description
Β§π₯ afire

afire is a blazingly fast web server micro framework for rust.
Β§π Install
Just add the following to your Cargo.toml
:
[dependencies]
afire = "2.2.1"
Β§π Info
afire is a simple synchronous multithreaded express.js inspired rust web micro framework. wow that was long. It comes with some built extensions in for Static File Serving, Rate limiting, and more.
Below you can find links to some afire related resources.
Β§π₯ Example
For more examples see the examples directory here.
Below is a super simple example so you can see the basics of afire syntax.
// Import Lib
use afire::{Server, Method, Response, Header, Content};
// Create Server
let mut server = Server::<()>::new("localhost", 8080);
// Add a route
server.route(Method::GET, "/greet/{name}", |req| {
let name = req.param("name").unwrap();
Response::new()
.text(format!("Hello, {}", name))
.content(Content::TXT)
});
// Start the server
// This is blocking
server.start().unwrap();
Β§πΌ License
afire is licensed under the MIT license so you are free to do basically whatever you want with it as long as you add a copyright notice. You can read the full license text here.
Re-exports§
pub use self::error::Error;
pub use self::middleware::Middleware;
Modules§
- cookie
- Cookies! This module provides a simple interface for setting and receiving cookies.
- error
- Errors that can occur in the process of connecting to clients, parsing HTTP and handling requests.
- extension
- Useful extensions to the base afire. Includes helpful middleware like Serve Static, Rate Limit and Logger.
- header
- HTTP headers.
- internal
- Internal Functions
- middleware
- Middleware is code that runs before and after the routes. They can be used to Log Requests, Ratelimit Requests, add Analytics, etc. For more information, see the Middleware Example.
- multipart
- Multipart request parsing.
- prelude
- The Prelude is a collection of very commonly used things in afire. Unless you are using middleware, extensions or internal lower level stuff this should be all you need!
- server_
sent_ events - Server-sent event (SSE) support.
- trace
- Basic built-in logging system
Macros§
- trace
- Simple logging system.
See
crate::trace
for more information.
Structs§
- Cookie
- Represents a Cookie
- Header
- Http header. Has a name and a value.
- Query
- Collection of query parameters.
Can be made from the query string of a URL, or the body of a POST request.
Similar to
crate::header::Headers
. - Request
- Http Request
- Response
- Http Response
- Route
- Defines a route.
- Server
- Defines a server.
- SetCookie
- Represents a Set-Cookie header. Has more information than a normal Cookie (e.g. max-age, domain, path, secure).
Enums§
- Content
- Common MIME types.
- Header
Type - Common HTTP headers. Just the βcommonβ ones, which are ones that I use semi-frequently, or that are used internally.
- Method
- HTTP Methods.
- Status
- HTTP status codes.
Used in
crate::Request
andcrate::Response
.