Builtin

http.hh

http.hh

Returns the heading for an http handler. i.e. the request and the corresponding response definition:

┌─────────────────────────────────────────────────────────┬────────────┐
│ type                                                    │ attr       │
├─────────────────────────────────────────────────────────┼────────────┤
│ str                                                     │ method     │
│ str                                                     │ path       │
│ {k:str,v:str}                                           │ path_value │
│ {k:str,seq:int,v:str}                                   │ header     │
│ {k:str,v:str}                                           │ cookie     │
│ str                                                     │ body       │
│ {k:str,seq:int,v:str}                                   │ form       │
│ tuple{header:{k:str,seq:int,v:str},status:int,body:str} │ response   │
└─────────────────────────────────────────────────────────┴────────────┘

This can be used as a dynamic template for route relgen handlers.

Examples

route relgen handler
import("http")

index_handler := {attr_types(http.hh)} begin
    response := http.response{*, body := "Hello world, wide web"}
    yield
end