🚧 Prototype Notice

This project (sufast) is currently a dummy prototype.
Only static routes are working at the moment.
Dynamic routing and full features are under development.
Thank you for understanding! 🙏

Sufast/Documentation
Request Object

Request Object Reference

Complete guide to accessing and processing HTTP request data in Sufast applications.

Request Properties
Access request metadata and information
PropertyTypeDescriptionExample
request.methodstrHTTP method"GET", "POST"
request.urlURLComplete request URLURL object
request.headersHeadersRequest headersHeaders object
request.query_paramsQueryParamsURL query parametersQueryParams object
request.path_paramsdictPath parameters{'user_id': '123'}
request.cookiesdictRequest cookies{'session': 'abc123'}
request.clientAddressClient IP and portAddress object
request.stateStateRequest-scoped stateState object

Basic Property Usage

Request Propertiespython
from sufast import App, Request

app = App()

@app.get("/info")
def request_info(request: Request):
    return {
        "method": request.method,
        "url": str(request.url),
        "path": request.url.path,
        "query": str(request.url.query),
        "scheme": request.url.scheme,
        "hostname": request.url.hostname,
        "port": request.url.port,
        "client_ip": request.client.host,
        "client_port": request.client.port,
        "user_agent": request.headers.get("user-agent"),
        "content_type": request.headers.get("content-type"),
        "content_length": request.headers.get("content-length"),
    }

@app.get("/users/{user_id}")
def get_user_info(request: Request):
    user_id = request.path_params["user_id"]
    
    # Access query parameters
    include_posts = request.query_params.get("include_posts", "false") == "true"
    limit = int(request.query_params.get("limit", "10"))
    
    return {
        "user_id": user_id,
        "include_posts": include_posts,
        "limit": limit,
        "request_id": id(request)  # Unique request identifier
    }