Skip to main content

Crate volga

Crate volga 

Source
Expand description

§Volga

Fast, Easy, and very flexible Web Framework for Rust based on Tokio runtime and hyper for fun and painless microservices crafting.

§Features

  • Supports HTTP/1 and HTTP/2
  • Robust routing
  • Custom middlewares
  • Dependency Injection
  • WebSockets and WebSocket-over-HTTP/2
  • Full Tokio compatibility
  • Runs on stable Rust 1.80+

§Example

use volga::*;
 
#[tokio::main]
async fn main() -> std::io::Result<()> {
    // Start the server
    let mut app = App::new();
 
    // Example of a request handler
    app.map_get("/hello/{name}", async |name: String| {
         ok!("Hello {name}!")
    });
     
    app.run().await
}

Re-exports§

pub use crate::app::App;
pub use crate::http::response::builder::RESPONSE_ERROR;
pub use crate::http::response::builder::SERVER_NAME;
pub use crate::http::endpoints::args::cancellation_token::CancellationToken;
pub use crate::http::endpoints::args::file::File;
pub use crate::http::endpoints::args::json::Json;
pub use crate::http::endpoints::args::path::Path;
pub use crate::http::endpoints::args::path::NamedPath;
pub use crate::http::endpoints::args::query::Query;
pub use crate::http::endpoints::args::form::Form;
pub use crate::http::endpoints::args::client_ip::ClientIp;
pub use crate::http::endpoints::args::byte_stream::ByteStream;
pub use crate::http::BoxBody;
pub use crate::http::UnsyncBoxBody;
pub use crate::http::HttpBody;
pub use crate::http::HttpRequest;
pub use crate::http::HttpResponse;
pub use crate::http::HttpResult;
pub use http::HttpRequestMut;
pub use limits::Limit;
pub use crate::http::endpoints::args::multipart::Multipart;

Modules§

app
Main application entry point
auth
Tools and utils for Authorization & Authentication
di
Tools for Dependency Injection
error
Error Handling tools
fs
File System tools and abstractions
headers
Tools for HTTP headers
http
Base HTTP tools
json
Tools for JSON format
limits
Resource limits and backpressure configuration.
middleware
Middleware tools
openapi
OpenAPI registry and configuration.
rate_limiting
Tools and utilities for Rate Limiting
routing
Route mapping helpers
test
Test utilities for building and running Volga applications in integration tests.
tls
HTTPS/TLS protocol implementations and middlewares
tracing
Tools for tracing, logging and observability
utils
Utilities and reusable helpers
ws
WebSockets and WebSocket-over-HTTP/2 protocol implementation and tools

Macros§

accepted
Produces HTTP 202 ACCEPTED response
bad_request
Produces HTTP 400 BAD REQUEST response
builder
Creates a default HTTP response builder
byte_stream
Creates an asynchronous stream
claims
Declares a structure as JWT claims and implements AuthClaims trait
created
Produces HTTP 201 CREATED response
file
Produces OK 200 response with file body
form
Produces OK 200 response with Form Data body
found
Produces HTTP 302 FOUND response
headers
Declares a custom HTTP headers structure
html
Produces OK 200 response with HTML body
html_file
Produces OK 200 response with HTML file body
no_content
Produces NO CONTENT 204 response
not_found
Produces HTTP 404 NOT FOUND response
ok
Creates a 200 OK response.
permanent_redirect
Produces HTTP 308 PERMANENT REDIRECT response
problemDeprecated
Produces an error response in the Problem Details format
redirect
Produces HTTP 301 MOVED PERMANENTLY response
response
Creates an HTTP response with status, body and headers
see_other
Produces HTTP 303 SEE OTHER response
sse
Produces OK 200 response with SSE (Server-Sent Events) stream body
sse_stream
Creates an asynchronous SSE stream
status
Produces a response with the specified HTTP status code.
stream
Produces OK 200 response with stream body
temp_redirect
Produces HTTP 307 TEMPORARY REDIRECT response