context

package
v0.0.0-...-c0c7c65 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddListeners

func AddListeners(ls ...*Listener)

AddListeners add listeners

func ClearListeners

func ClearListeners()

ClearListeners clear listeners

Types

type Context

type Context struct {
	Request  *http.Request
	Response *Response

	MultipartMap map[string][]*MultipartFile
	// contains filtered or unexported fields
}

Context struct

func New

func New(r *http.Request, templateConfig *config.Template) *Context

New context

func (*Context) Add

func (ctx *Context) Add(handlers ...func(ctx *Context)) *Context

Add context handler

func (*Context) AddCookie

func (ctx *Context) AddCookie(cookies ...*http.Cookie) *Context

AddCookie add cookie

func (*Context) AddFunc

func (ctx *Context) AddFunc(name string, funcMap interface{}) *Context

AddFunc add func

func (*Context) AddFuncMap

func (ctx *Context) AddFuncMap(funcMap template.FuncMap) *Context

AddFuncMap add funcMap

func (*Context) BMP

func (ctx *Context) BMP(buffer []byte)

BMP Response bmp

func (*Context) BMPFSFile

func (ctx *Context) BMPFSFile(fs *embed.FS, name string)

BMPFSFile Response bmp FS file

func (*Context) BMPFile

func (ctx *Context) BMPFile(bmpFile string)

BMPFile Response bmp file

func (*Context) Binary

func (ctx *Context) Binary(buffer []byte, contentType string)

Binary Response bin

func (*Context) Bind

func (ctx *Context) Bind(structPtr interface{})

Bind struct ptr

func (*Context) CSS

func (ctx *Context) CSS(css string)

CSS Response css

func (*Context) CSSFSFile

func (ctx *Context) CSSFSFile(fs *embed.FS, name string)

CSSFSFile Response css FS file

func (*Context) CSSFile

func (ctx *Context) CSSFile(cssFile string)

CSSFile Response css file

func (*Context) Chain

func (ctx *Context) Chain()

Chain execute context handler

func (*Context) Data

func (ctx *Context) Data(data []byte) *Context

Data buffer

func (*Context) Download

func (ctx *Context) Download(file, filename string)

Download Response download

func (*Context) FSFile

func (ctx *Context) FSFile(fs *embed.FS, name, contentType string)

FSFile Response file

func (*Context) File

func (ctx *Context) File(file, contentType string)

File Response file

func (*Context) FloatParam

func (ctx *Context) FloatParam(name string, defaultVal float64) float64

FloatParam return named param of float

func (*Context) GIF

func (ctx *Context) GIF(buffer []byte)

GIF Response gif

func (*Context) GIFFSFile

func (ctx *Context) GIFFSFile(fs *embed.FS, name string)

GIFFSFile Response gif FS file

func (*Context) GIFFile

func (ctx *Context) GIFFile(gifFile string)

GIFFile Response gif file

func (*Context) GetData

func (ctx *Context) GetData(name string) interface{}

GetData get data from context

func (*Context) GetDataMap

func (ctx *Context) GetDataMap() map[string]interface{}

GetDataMap get data map from context

func (*Context) HTML

func (ctx *Context) HTML(html string)

HTML Response html

func (*Context) HTMLFSFile

func (ctx *Context) HTMLFSFile(fs *embed.FS, name string)

HTMLFSFile Response html FS file

func (*Context) HTMLFile

func (ctx *Context) HTMLFile(htmlFile string)

HTMLFile Response html file

func (*Context) HasParam

func (ctx *Context) HasParam(name string) bool

HasParam return true if named param in param map

func (*Context) Header

func (ctx *Context) Header(header http.Header) *Context

Header return header

func (*Context) ICO

func (ctx *Context) ICO(buffer []byte)

ICO Response ico

func (*Context) ICOFSFile

func (ctx *Context) ICOFSFile(fs *embed.FS, name string)

ICOFSFile Response ico FS file

func (*Context) ICOFile

func (ctx *Context) ICOFile(icoFile string)

ICOFile Response ico file

func (*Context) Image

func (ctx *Context) Image(buffer []byte)

Image Response image

func (*Context) ImageFSFile

func (ctx *Context) ImageFSFile(fs *embed.FS, name string)

ImageFSFile Response image FS file

func (*Context) ImageFile

func (ctx *Context) ImageFile(imageFile string)

ImageFile Response image file

func (*Context) IntKey

func (ctx *Context) IntKey() int64

IntKey return int REST-ful key

func (*Context) IntParam

func (ctx *Context) IntParam(name string, defaultVal int64) int64

IntParam return named param of int with default `defaultVal`

func (*Context) JPEG

func (ctx *Context) JPEG(buffer []byte)

JPEG Response jpeg

func (*Context) JPEGFSFile

func (ctx *Context) JPEGFSFile(fs *embed.FS, name string)

JPEGFSFile Response jpeg FS file

func (*Context) JPEGFile

func (ctx *Context) JPEGFile(jpegFile string)

JPEGFile Response jpeg file

func (*Context) JPG

func (ctx *Context) JPG(buffer []byte)

JPG Response jpg

func (*Context) JPGFSFile

func (ctx *Context) JPGFSFile(fs *embed.FS, name string)

JPGFSFile Response jpg FS file

func (*Context) JPGFile

func (ctx *Context) JPGFile(jpgFile string)

JPGFile Response jpg file

func (*Context) JS

func (ctx *Context) JS(js string)

JS Response js

func (*Context) JSFSFile

func (ctx *Context) JSFSFile(fs *embed.FS, name string)

JSFSFile Response js FS file

func (*Context) JSFile

func (ctx *Context) JSFile(jsFile string)

JSFile Response js file

func (*Context) JSON

func (ctx *Context) JSON(data interface{})

JSON Response JSON

func (*Context) JSONFSFile

func (ctx *Context) JSONFSFile(fs *embed.FS, name string)

JSONFSFile Response JSON FS file

func (*Context) JSONFile

func (ctx *Context) JSONFile(jsonFile string)

JSONFile Response JSON file

func (*Context) JSONText

func (ctx *Context) JSONText(json string)

JSONText Response JSON text

func (*Context) JoinedParamMap

func (ctx *Context) JoinedParamMap(separator string) map[string]string

JoinedParamMap return joined single value param map

func (*Context) Key

func (ctx *Context) Key() string

Key return REST-ful key

func (*Context) MultipartFile

func (ctx *Context) MultipartFile(name string) *MultipartFile

MultipartFile get multiple file

func (*Context) MultipartFiles

func (ctx *Context) MultipartFiles(name string) []*MultipartFile

MultipartFiles get multiple files

func (*Context) PNG

func (ctx *Context) PNG(buffer []byte)

PNG Response png

func (*Context) PNGFSFile

func (ctx *Context) PNGFSFile(fs *embed.FS, name string)

PNGFSFile Response png FS file

func (*Context) PNGFile

func (ctx *Context) PNGFile(pngFile string)

PNGFile Response png file

func (*Context) Param

func (ctx *Context) Param(name string) string

Param return named param

func (*Context) ParamDefault

func (ctx *Context) ParamDefault(name, defaultVal string) string

ParamDefault return named param

func (*Context) ParamMap

func (ctx *Context) ParamMap() map[string][]string

ParamMap return param map

func (*Context) Params

func (ctx *Context) Params(name string, defaultVal []string) []string

Params return named param values

func (*Context) ParseMultipart

func (ctx *Context) ParseMultipart(maxMemory int64)

ParseMultipart parse multiple Request

func (*Context) Redirect

func (ctx *Context) Redirect(url string)

Redirect url

func (*Context) SetData

func (ctx *Context) SetData(name string, value interface{}) *Context

SetData Set data into context

func (*Context) SetDataMap

func (ctx *Context) SetDataMap(dataMap map[string]interface{}, flush bool) *Context

SetDataMap Set data map into context

func (*Context) SetParamMap

func (ctx *Context) SetParamMap(paramMap map[string][]string, flush bool) *Context

SetParamMap set param map

func (*Context) SingleParamMap

func (ctx *Context) SingleParamMap() map[string]string

SingleParamMap return single value param map

func (*Context) Status

func (ctx *Context) Status(status int) *Context

Status code

func (*Context) Template

func (ctx *Context) Template(tpl string, data map[string]interface{})

Template Response template

func (*Context) TemplateFS

func (ctx *Context) TemplateFS(FS *embed.FS, prefix string, data map[string]interface{})

TemplateFS Response template with rFS

func (*Context) TemplateFile

func (ctx *Context) TemplateFile(prefix string, data map[string]interface{})

TemplateFile Response template with file

func (*Context) Text

func (ctx *Context) Text(text string)

Text Response text

func (*Context) TextFSFile

func (ctx *Context) TextFSFile(fs *embed.FS, name string)

TextFSFile Response text FS file

func (*Context) TextFile

func (ctx *Context) TextFile(textFile string)

TextFile Response text file

func (*Context) Write

func (ctx *Context) Write(r *Response)

Write from r

func (*Context) XML

func (ctx *Context) XML(data interface{})

XML Response XML

func (*Context) XMLFSFile

func (ctx *Context) XMLFSFile(fs *embed.FS, name string)

XMLFSFile Response XML FS file

func (*Context) XMLFile

func (ctx *Context) XMLFile(xmlFile string)

XMLFile Response XML file

func (*Context) XMLText

func (ctx *Context) XMLText(xml string)

XMLText Response XML text

type Listener

type Listener struct {
	// Created Listener
	Created func(c *Context)
	// Destroyed Listener
	Destroyed func(c *Context)
}

Listener interface

type MultipartFile

type MultipartFile struct {
	// ContentType Content type
	ContentType string
	// FileHeader file headers
	FileHeader *multipart.FileHeader
}

MultipartFile struct

func (*MultipartFile) Copy

func (file *MultipartFile) Copy(distName string)

Copy source file in multiple

type Response

type Response struct {
	Data        []byte
	Header      http.Header
	Cookies     []*http.Cookie
	Status      int
	ContentType string
}

Response struct

type ResponseBuilder

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

ResponseBuilder struct

func Builder

func Builder() *ResponseBuilder

Builder Response

func (*ResponseBuilder) Build

func (r *ResponseBuilder) Build() *Response

Build Response

func (*ResponseBuilder) ContentType

func (r *ResponseBuilder) ContentType(contentType string) *ResponseBuilder

ContentType Response

func (*ResponseBuilder) Cookies

func (r *ResponseBuilder) Cookies(cookies []*http.Cookie) *ResponseBuilder

Cookies Response

func (*ResponseBuilder) Data

func (r *ResponseBuilder) Data(data []byte) *ResponseBuilder

Data Response

func (*ResponseBuilder) DefaultBuild

func (r *ResponseBuilder) DefaultBuild() *Response

DefaultBuild Response

func (*ResponseBuilder) Header

func (r *ResponseBuilder) Header(header http.Header) *ResponseBuilder

Header Response

func (*ResponseBuilder) Status

func (r *ResponseBuilder) Status(status int) *ResponseBuilder

Status Response

Jump to

Keyboard shortcuts

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