Documentation ¶
Overview ¶
The global context package enables reading the request and sending a response.
// Pipe the request body to the response. context.req.body.pipe(context.res.body); // Or let the response consume the request. context.res.body.consume(context.req.body); // And set http response headers. context.head('Content-Type', 'application/pdf'); context.head('Content-Description', 'File Transfer'); context.head('Content-Transfer-Encoding', 'binary'); context.head('Content-Disposition', 'inline; filename="demo.pdf"');
Index ¶
- func New(orb *orbit.Orbit) interface{}
- type Module
- func (this *Module) Cbor(data interface{})
- func (this *Module) Failure()
- func (this *Module) Head(key, val string)
- func (this *Module) Html(data interface{})
- func (this *Module) Json(data interface{})
- func (this *Module) Pack(data interface{})
- func (this *Module) Render(file string, args ...interface{})
- func (this *Module) Status(code int) *Status
- func (this *Module) Success()
- func (this *Module) Text(data interface{})
- func (this *Module) Xml(data interface{})
- type Request
- type Response
- type Status
- func (this *Status) Cbor(data interface{})
- func (this *Status) Done()
- func (this *Status) Head(key, val string) *Status
- func (this *Status) Html(data interface{})
- func (this *Status) Json(data interface{})
- func (this *Status) Pack(data interface{})
- func (this *Status) Text(data interface{})
- func (this *Status) Xml(data interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Module ¶
type Module struct { // Req represents the http request of the // function runtime, enabling processing // the http request details and data. Req *Request `console:"req"` // Res represents the http response of the // function runtime, enabling sending data // back to the requesting http client. Res *Response `console:"res"` // contains filtered or unexported fields }
func (*Module) Failure ¶
func (this *Module) Failure()
Failure enables sending only an http 400 failure status code to the http client.
func (*Module) Head ¶
Head enables defining the http headers which are to be sent with the response.
func (*Module) Status ¶
Status enables defining the http status code, with a chained method to send the data using different encoding types.
type Request ¶
type Request struct { // Body represents the http request body of the // current function request. THe body can be // read or streamed as needed. Body *stream.Reader `console:"body"` // Head is an object containing the http // headers of the current request. Head map[string]string `console:"head"` // Method is the http method used when making // this request. It should be one of GET, PUT, // POST, PATCH, DELETE, TRACE, OPTIONS, HEAD. Method string `console:"method"` // User is the basic auth username used for // this request. If no username was specified // or no basic auth details were used then // this will ne an empty string. User string `console:"user"` // Pass is the basic auth password used for // this request. If no password was specified // or no basic auth details were used then // this will ne an empty string. Pass string `console:"pass"` // Host is the specific of the web host name // used when requesting this function request. Host string `console:"host"` // Path is the specific path used when running // this function. If the request was without a // url path, then this will be an empty string. Path string `console:"path"` // If the request url of the current request // contains any query paramaters, then this will // be populated with the full http query string. Query string `console:"query"` // IP is the parsed ipv4 or ipv6 address of the // client who has made the http request. It will // always be specified, and will never be empty. IP string `console:"ip"` // contains filtered or unexported fields }
func NewRequest ¶
type Response ¶
type Response struct { // Body represents the http response body of the // current function request. The body can be // can be written or streamed to. Body *stream.Writer `console:"body"` // contains filtered or unexported fields }
func NewResponse ¶
Click to show internal directories.
Click to hide internal directories.