← all modules
module

stdlib::http::typed

defined in C:\Users\bye45\.glide\bin/src/stdlib/http/typed.glide

Generic wrapper around a value that should be serialised as the

struct struct Json

Generic wrapper around a value that should be serialised as the JSON body of an HTTP response. The struct is intentionally a single-field carrier — the value gets to into_response() via the IntoResponse impl below, which calls T.to_json() (so T must implement JsonBind).

glide
Build:
let r: HttpResponse = json_respond(StructLegal { nome: "alice", idade: some(30) });
fn fn json_respond(v: T) -> HttpResponse

One-step from typed value to HttpResponse via the IntoResponse trait. Equivalent to Json::wrap(v).into_response() but spelt as a free fn so the chained dispatch monomorphizes cleanly across the call boundary.

glide
fn create(req: *HttpRequest) -> HttpResponse {
    let user: StructLegal = /* ... */;
    return json_respond(user);
}
trait trait IntoResponse

Convert any "response-shaped" value into a final HttpResponse the server loop can write to the wire. Implemented for HttpResponse itself (identity) and for Json<T> when T binds to JSON. Future implementors might cover string (text reply), ?T, error types, etc.; nothing in stdlib::http::router calls into_response today, so impls are purely for handler-tail ergonomics.