context

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2021 License: Apache-2.0 Imports: 21 Imported by: 6

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 Builder

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

Builder struct

func RenderBuilder

func RenderBuilder() *Builder

RenderBuilder render

func (*Builder) Buffer

func (r *Builder) Buffer(buffer []byte) *Builder

Buffer render

func (*Builder) Build

func (r *Builder) Build() *Render

Build render

func (*Builder) Code

func (r *Builder) Code(code int) *Builder

Code render

func (*Builder) ContentType

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

ContentType render

func (*Builder) Cookies

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

Cookies render

func (*Builder) DefaultBuild

func (r *Builder) DefaultBuild() *Render

DefaultBuild render

func (*Builder) Header

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

Header render

type Context

type Context struct {
	Logger  *logrus.Logger
	Request *http.Request

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

Context struct

func New

func New(logger *logrus.Logger, 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 render bmp

func (*Context) BMPFSFile

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

BMPFSFile render bmp rFS file

func (*Context) BMPFile

func (ctx *Context) BMPFile(bmpFile string)

BMPFile render bmp file

func (*Context) Binary

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

Binary render bin

func (*Context) Bind

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

Bind struct ptr

func (*Context) BindAndValidate

func (ctx *Context) BindAndValidate(structPtr interface{}, call func())

BindAndValidate struct ptr

func (*Context) BindAndValidateWithParams

func (ctx *Context) BindAndValidateWithParams(structPtr interface{}, messageName, message, codeName string, code int, call func())

BindAndValidateWithParams struct ptr

func (*Context) CSS

func (ctx *Context) CSS(css string)

CSS render css

func (*Context) CSSFSFile

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

CSSFSFile render css rFS file

func (*Context) CSSFile

func (ctx *Context) CSSFile(cssFile string)

CSSFile render css file

func (*Context) Chain

func (ctx *Context) Chain()

Chain execute context handler

func (*Context) Download

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

Download render download

func (*Context) FSFile

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

FSFile render file

func (*Context) File

func (ctx *Context) File(file string)

File render 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 render gif

func (*Context) GIFFSFile

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

GIFFSFile render gif rFS file

func (*Context) GIFFile

func (ctx *Context) GIFFile(gifFile string)

GIFFile render 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 render html

func (*Context) HTMLFSFile

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

HTMLFSFile render html rFS file

func (*Context) HTMLFile

func (ctx *Context) HTMLFile(htmlFile string)

HTMLFile render 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() http.Header

Header return header

func (*Context) ICO

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

ICO render ico

func (*Context) ICOFSFile

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

ICOFSFile render ico rFS file

func (*Context) ICOFile

func (ctx *Context) ICOFile(icoFile string)

ICOFile render ico file

func (*Context) Image

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

Image render image

func (*Context) ImageFSFile

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

ImageFSFile render image rFS file

func (*Context) ImageFile

func (ctx *Context) ImageFile(imageFile string)

ImageFile render 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 render jpeg

func (*Context) JPEGFSFile

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

JPEGFSFile render jpeg rFS file

func (*Context) JPEGFile

func (ctx *Context) JPEGFile(jpegFile string)

JPEGFile render jpeg file

func (*Context) JPG

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

JPG render jpg

func (*Context) JPGFSFile

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

JPGFSFile render jpg rFS file

func (*Context) JPGFile

func (ctx *Context) JPGFile(jpgFile string)

JPGFile render jpg file

func (*Context) JS

func (ctx *Context) JS(js string)

JS render js

func (*Context) JSFSFile

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

JSFSFile render js rFS file

func (*Context) JSFile

func (ctx *Context) JSFile(jsFile string)

JSFile render js file

func (*Context) JSON

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

JSON render JSON

func (*Context) JSONFSFile

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

JSONFSFile render JSON rFS file

func (*Context) JSONFile

func (ctx *Context) JSONFile(jsonFile string)

JSONFile render JSON file

func (*Context) JSONText

func (ctx *Context) JSONText(json string)

JSONText render 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 render png

func (*Context) PNGFSFile

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

PNGFSFile render png rFS file

func (*Context) PNGFile

func (ctx *Context) PNGFile(pngFile string)

PNGFile render png file

func (*Context) Param

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

Param 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) error

ParseMultipart parse multiple Request

func (*Context) Redirect

func (ctx *Context) Redirect(url string)

Redirect url

func (*Context) Render

func (ctx *Context) Render(r *Render)

Render from r

func (*Context) Rendered

func (ctx *Context) Rendered() *Render

Rendered panic(err) the render

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) Template

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

Template render template

func (*Context) TemplateFS

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

TemplateFS render template with rFS

func (*Context) TemplateFile

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

TemplateFile render template with file

func (*Context) Text

func (ctx *Context) Text(text string)

Text render text

func (*Context) TextFSFile

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

TextFSFile render text rFS file

func (*Context) TextFile

func (ctx *Context) TextFile(textFile string)

TextFile render text file

func (*Context) Validate

func (ctx *Context) Validate(structPtr interface{}, call func())

Validate struct ptr

func (*Context) ValidateWithParams

func (ctx *Context) ValidateWithParams(structPtr interface{}, messageName, message, codeName string, code int, call func())

ValidateWithParams struct ptr

func (*Context) Write

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

Write buffer

func (*Context) WriteCode

func (ctx *Context) WriteCode(code int)

WriteCode code

func (*Context) XML

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

XML render XML

func (*Context) XMLFSFile

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

XMLFSFile render XML rFS file

func (*Context) XMLFile

func (ctx *Context) XMLFile(xmlFile string)

XMLFile render XML file

func (*Context) XMLText

func (ctx *Context) XMLText(xml string)

XMLText render 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) error

Copy source file in multiple

type Render

type Render struct {
	Buffer      []byte
	Header      http.Header
	Cookies     []*http.Cookie
	Code        int
	ContentType string
}

Render struct

Jump to

Keyboard shortcuts

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