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 versioning, documentation, and OpenAPI support
app
cache
High-performance caching with Redis and in-memory support
config
Configuration system for Torch framework
database
Database integration with connection pooling and query builder
ember
Ember Template Engine
error_pages
extractors
Extractors
handler
macros
Torch Compile-Time Route Registration
middleware
production
Production-ready features for high-scale applications
request
response
router
security
Security middleware and utilities for Torch framework
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.