param

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0, Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertParams

func ConvertParams(methodParams []*MethodParam, methodType reflect.Type, ctx *beecontext.Context) (result []reflect.Value)

ConvertParams converts http method params to values that will be passed to the method controller as arguments

Types

type MethodParam

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

MethodParam keeps param information to be auto passed to controller methods

func Make

func Make(list ...*MethodParam) []*MethodParam

Make creates an array of MethodParmas or an empty array

func New

func New(name string, opts ...MethodParamOption) *MethodParam

New creates a new MethodParam with name and specific options

func (*MethodParam) String

func (mp *MethodParam) String() string

type MethodParamOption

type MethodParamOption func(*MethodParam)

MethodParamOption defines a func which apply options on a MethodParam

var InBody MethodParamOption = func(p *MethodParam) {
	p.in = body
}

InBody indicates that this param is passed as an http request body

var InHeader MethodParamOption = func(p *MethodParam) {
	p.in = header
}

InHeader indicates that this param is passed via an http header

var InPath MethodParamOption = func(p *MethodParam) {
	p.in = path
}

InPath indicates that this param is part of the URL path

var IsRequired MethodParamOption = func(p *MethodParam) {
	p.required = true
}

IsRequired indicates that this param is required and can not be omitted from the http request

func Default

func Default(defaultValue interface{}) MethodParamOption

Default provides a default value for the http param

Jump to

Keyboard shortcuts

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