web

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GET    = "GET"
	POST   = "POST"
	PUT    = "PUT"
	PATCH  = "PATCH"
	DELETE = "DELETE"
	STATIC = "STATIC"
)
View Source
const (
	Path      = "path"
	Query     = "query"
	Body      = "body"
	Header    = "header"
	Form      = "form"
	Multipart = "multipart"
	Context   = "context"
	Request   = "request"
	Response  = "response"
	App       = "app"
	Stream    = "stream"
)

Variables

View Source
var (
	MethodDefine  = []string{GET, POST, PUT, PATCH, DELETE, STATIC}
	SourceDefine  = []string{Path, Query, Body, Form, Header, Multipart, Context, Request, Response, App, Stream}
	DefaultSource = Query
)

Functions

This section is empty.

Types

type API added in v1.1.5

type API string

type ApiHandler added in v1.3.0

type ApiHandler func(apiInfo *ApiInfo, funcType reflect.Method, funcValue reflect.Value)

type ApiInfo added in v1.3.0

type ApiInfo struct {
	HttpMethod string
	URL        string
	ApiDesc    string
	Params     []Param
}

type Configure added in v1.2.6

type Configure struct {
	bean.Component
	Charset string `yaml:"charset"`
}

func (*Configure) Prefix added in v1.2.6

func (c *Configure) Prefix() string

type Container added in v1.1.5

type Container interface {
	bean.Bean
	ApiHandler() ApiHandler
	StaticHandler() StaticHandler
	ListenAndServe(port int)
}

type Filter added in v1.1.5

type Filter interface {
	bean.Bean
	Order() int
	UrlPatterns() Patterns
	DoFilter(w http.ResponseWriter, r *http.Request, chain FilterChain) error
}

type FilterChain added in v1.1.8

type FilterChain interface {
	GetFilter() Filter
	SetNext(chain FilterChain)
	GetNext() FilterChain
	DoFilter(w http.ResponseWriter, r *http.Request) error
	SetService(service Service)
	DoService(w http.ResponseWriter, r *http.Request) error
}

type Param added in v1.3.0

type Param struct {
	Name   string
	Source string
	Type   reflect.Type
}

type ParamMapper added in v1.3.0

type ParamMapper interface {
	//PathParamMapper
	GetStringFromPath(param Param) string
	GetIntFromPath(param Param) int
	GetBoolFromPath(param Param) bool
	GetFloatFromPath(param Param) float64
	//QueryParamMapper
	GetStringFromQuery(param Param) string
	GetIntFromQuery(param Param) int
	GetBoolFromQuery(param Param) bool
	GetFloatFromQuery(param Param) float64
	GetStructFromQuery(param Param) interface{}
	//BodyParamMapper
	GetStructFromBody(param Param) interface{}
	GetMapFromBody(param Param) interface{}
	//HeaderParamMapper
	GetStringFromHeader(param Param) string
	//FormParamMapper
	GetStringFromForm(param Param) string
	GetIntFromForm(param Param) int
	GetBoolFromForm(param Param) bool
	GetFloatFromForm(param Param) float64
	GetMapFromForm() map[string][]string
	//UploadMapper
	GetStringFromMultipart(param Param) string
	GetMultipartHeader(param Param) *multipart.FileHeader
	GetMultipartFile(param Param) multipart.File
	GetStream() []byte
	//HttpMapper
	GetRequest() *http.Request
	GetResponseWriter() http.ResponseWriter
	//ExtendedParamMapper
	Get(param Param) interface{}
}

type Patterns added in v1.2.2

type Patterns []string

type Service added in v1.1.9

type Service func(w http.ResponseWriter, r *http.Request) error

type StaticHandler added in v1.3.2

type StaticHandler func(url, dir string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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