Crate torch_web

Source
Expand description

§Torch Web Framework

A fast, secure web framework that gets out of your way. Built for developers who need production-ready features without the complexity.

§Quick Start

use torch_web::{App, Request, Response};

#[tokio::main]
async fn main() {
    let app = App::new()
        .get("/", |_req: Request| async {
            Response::ok().body("Hello, World!")
        })
        .get("/users/:id", |req: Request| async move {
            let id = req.param("id").unwrap();
            Response::ok().body(format!("User ID: {}", id))
        });

    app.listen("127.0.0.1:3000").await.unwrap();
}

Re-exports§

pub use app::App;
pub use error_pages::ErrorPages;
pub use handler::Handler;
pub use handler::HandlerFn;
pub use request::Request;
pub use response::Response;
pub use router::Router;

Modules§

api
API Development and Documentation
app
Application Builder
cache
High-Performance Caching
config
Configuration system for Torch framework
database
Database Integration
ember
Ember Template Engine
error_pages
extractors
Request Extractors
handler
macros
Torch Compile-Time Route Registration
middleware
Middleware System
production
Production-Ready Features
request
HTTP Request Handling
response
HTTP Response Building
router
HTTP Router
security
Security Middleware and Utilities
server
websocket
WebSocket Support for Real-Time Applications

Macros§

delete
get
Attribute macro for route registration (placeholder for proc macro)
handler
A convenience macro for creating simple handlers
json
Construct a serde_json::Value from a JSON literal.
post
put
route_table
Macro for generating compile-time route tables
routes
Compile-time route registration macro
torch_handler
Macro for generating type-safe route handlers

Structs§

HeaderMap
A set of HTTP headers
HeaderName
Represents an HTTP header field name
HeaderValue
Represents an HTTP header field value.
Method
The Request Method (VERB)
StatusCode
An HTTP status code (status-code in RFC 9110 et al.).

Enums§

JsonValue
Represents any valid JSON value.

Attribute Macros§

main
Marks async function to be executed by the selected runtime. This macro helps set up a Runtime without requiring the user to use Runtime or Builder directly.