bodypredicate

package
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

README

body

The body predicate checks the Content-Type of the incoming request and/or parse its body.

Options

Option Required Description
mime If set, check that the Mime type of the Content-Type header value of the incoming request matches this value
type Can be string or json. If set, the body is read and parsed accordingly to this value.
limit Max body size in bytes. If received body is larger, it will be truncated. Default is 1232896 (1Mb).

Results

Field Type Description
result boolean false if mime was not matched (if set) or body cannot be parsed accordingly to type (if set) or method is GET, HEAD or DELETE
payload depends on type It type is set, contains the parsed body

Example:

- body:
    mime: application/json
    type: json
  register: body

- log:
    msg: body.payload.token

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Name = "body"

Name of the predicate

Functions

func New

func New() genapid.Predicate

New returns a new Predicate

Types

type Predicate

type Predicate struct {
	// contains filtered or unexported fields
}

Predicate is a genapid.Predicate interface that describes the predicate

func (*Predicate) Call

func (predicate *Predicate) Call(log zerolog.Logger, c *ctx.Ctx) bool

Call evaluates the predicate

func (*Predicate) Name

func (predicate *Predicate) Name() string

Name returns the name of the predicate

func (*Predicate) Params

func (predicate *Predicate) Params() interface{}

Params returns a reference to a struct params accepted by the predicate

func (*Predicate) Result

func (predicate *Predicate) Result() ctx.Result

Result returns data set by the predicate

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL