context

package
Version: v0.0.0-...-bdbbba5 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2021 License: Apache-2.0 Imports: 20 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

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

	MWData map[string]interface{}

	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 FS 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 FS 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) File

func (ctx *Context) File(file string)

File render file

func (*Context) FileFS

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

FileFS render file

func (*Context) Float

func (ctx *Context) Float(name string) float64

Float return named param of float

func (*Context) FloatDefault

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

FloatDefault 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 FS 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) 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 FS 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 FS 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 FS file

func (*Context) ImageFile

func (ctx *Context) ImageFile(imageFile string)

ImageFile render image file

func (*Context) Int

func (ctx *Context) Int(name string) (int64, error)

Int return named param of int

func (*Context) IntDefault

func (ctx *Context) IntDefault(name string, defaultVal int) int

IntDefault return named param of int with default `defaultVal`

func (*Context) IntKey

func (ctx *Context) IntKey() int64

IntKey return int REST-ful key

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 FS 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 FS 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 FS 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 FS 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) PNGFile

func (ctx *Context) PNGFile(pngFile string)

PNGFile render png file

func (*Context) PNGJSFile

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

PNGJSFile render png FS 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 with default value

func (*Context) ParamMap

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

ParamMap return param map

func (*Context) Params

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

Params return named param values

func (*Context) ParamsDefault

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

ParamsDefault return named param with default value

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

func (ctx *Context) Route()

Route once

func (*Context) Routed

func (ctx *Context) Routed() bool

Routed return handler routed

func (*Context) SetData

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

SetData Set data into context

func (*Context) SetDataMap

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

SetDataMap Set data map into context

func (*Context) SetParamMap

func (ctx *Context) SetParamMap(paramMap map[string][]string) *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(prefix string, data map[string]interface{})

Template render template

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 FS 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 FS 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 interface {
	// Created Listener
	Created(c *Context)
	// Before Listener
	Before(c *Context)
	// After Listener
	After(c *Context)
	// Destroyed Listener
	Destroyed(c *Context)
}

Listener interface

type MultipartFile

type MultipartFile struct {
	// Filename file name
	Filename string
	// ContentType Content type
	ContentType string
	// Size file's total size
	Size int64
	// FileHeader file headers
	FileHeader *multipart.FileHeader
	// Headers for Request
	Headers http.Header
}

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
t or T : Toggle theme light dark auto
y or Y : Canonical URL