Documentation
¶
Index ¶
- func AddLambdaToContext(parentCtx context.Context, l *Lambda) context.Context
- func NewRequestCtx(w http.ResponseWriter, r *http.Request) context.Context
- func NewTestCtx(method string, rawurl string, header http.Header, vars map[string]string) context.Context
- type Lambda
- func (l *Lambda) RequestBasicAuth() (username, password string, ok bool)
- func (l *Lambda) RequestBodyQueryParameters() url.Values
- func (l *Lambda) RequestHeader() http.Header
- func (l *Lambda) RequestHeaderGet(header string) string
- func (l *Lambda) RequestHeaderValues(header string) []string
- func (l *Lambda) RequestMethod() string
- func (l *Lambda) RequestQueryStringParameter(parameter string) string
- func (l *Lambda) RequestURL() *url.URL
- func (l *Lambda) RequestVars() map[string]string
- func (l *Lambda) ResponseHeader() http.Header
- func (l *Lambda) ResponseHeaderAdd(header, value string)
- func (l *Lambda) ResponseHeaderAddAs(header, value string)
- func (l *Lambda) ResponseHeaderSet(header, value string)
- func (l *Lambda) ResponseStatus(status int)
- func (l *Lambda) TraceID() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddLambdaToContext ¶ added in v1.9.0
AddLambdaToContext will return the context with value of Lambda
func NewRequestCtx ¶
NewRequestCtx adds request related data to r.Context(). You may use this at traditional http handler functions, and that is what happens at Lambda functions automatically. Returns new derived context. That can be used at client functions, silently propagating tracing headers.
E.g. ctx := NewRequestCtx(w, r)
Types ¶
type Lambda ¶
type Lambda struct {
// Status is the HTTP status code a function returnes with.
// See ResponseStatus method for details.
Status int
// Trace contains the tracing data of the handler context.
Trace tracedata.TraceData
// contains filtered or unexported fields
}
Lambda is lambda class. Usually it is available via lambda function context and provides data for header manipulation. Often accessed as restful.L(ctx).
func (*Lambda) RequestBasicAuth ¶
RequestBasicAuth returns the username and password provided in the request's Authorization header. Returned flag ok indicates if the header is received fine. That way one can tell if the header was received with empty strings or not.
func (*Lambda) RequestBodyQueryParameters ¶ added in v1.18.0
RequestBodyQueryParameters returns values of the request body query parameters when Content-Type is application/x-www-form-urlencoded.
func (*Lambda) RequestHeader ¶
RequestHeader returns the header map of received HTTP request.
func (*Lambda) RequestHeaderGet ¶
RequestHeaderGet returns value of header in received HTTP request.
func (*Lambda) RequestHeaderValues ¶
RequestHeaderValues returns all the values of header in received HTTP request.
func (*Lambda) RequestMethod ¶
RequestMethod returns request method
func (*Lambda) RequestQueryStringParameter ¶
RequestQueryStringParameter returns value of given path parameter of received HTTP request.
func (*Lambda) RequestURL ¶
RequestURL returns URL of received HTTP request.
func (*Lambda) RequestVars ¶
RequestVars returns all the named path or query parameters of received HTTP request.
func (*Lambda) ResponseHeader ¶
ResponseHeader return response header map to be sent. Usually used on testing.
func (*Lambda) ResponseHeaderAdd ¶
ResponseHeaderAdd adds an HTTP header to the response to be sent.
func (*Lambda) ResponseHeaderAddAs ¶
ResponseHeaderAddAs adds an HTTP header to the response to be sent. Header is set as provided, not changed to canonical form. As long as there is no specific reason, use ResponseHeaderAdd instead.
func (*Lambda) ResponseHeaderSet ¶
ResponseHeaderSet sets an HTTP header to the response to be sent.
func (*Lambda) ResponseStatus ¶
ResponseStatus sets HTTP status code to be sent. Use that if you want to set positive (non-error) status code.
restful.L(ctx).ResponseStatus(http.StatusAccepted)
Has no effect if lambda returns a non-nil error. In such case status is taken from the error (see restful.NewError), or 500 is returned.