core

package
v0.0.0-...-6599ed9 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Args

func Args(values ...interface{}) map[string]interface{}

模板传递多个变量 {{template "userlist" Args "Users" .MostPopular "Current" .CurrentUser}}

func DateFormat

func DateFormat(date time.Time, layout string) string

格式化时间

func DateFormatString

func DateFormatString(date string, layout string) string

格式化时间

func Handle

func Handle(handler IHandler) gin.HandlerFunc

func IsPage

func IsPage(url ...string) bool

func Middleware

func Middleware(handler IHandler) gin.HandlerFunc

func PageUrl

func PageUrl(uri string, page int) string

func SetTemplate

func SetTemplate(engine *gin.Engine)

func StartCron

func StartCron()

func StaticUrl

func StaticUrl(url ...string) string

返回资源路径

func Substr

func Substr(source string, start, end int) string

截取字符串

func Truncate

func Truncate(s string, n int) string

func Unescaped

func Unescaped(x string) interface{}

func WeekDayFormat

func WeekDayFormat(date time.Time) string

Types

type ApiResponse

type ApiResponse struct {
	HttpStatus int          `json:"-"`
	Context    *gin.Context `json:"-"`
	StatusCode int          `json:"statusCode"`
	Data       interface{}  `json:"data"`
	Message    string       `json:"message"`
}

func (*ApiResponse) Render

func (c *ApiResponse) Render()

type Context

type Context struct {
	*gin.Context
	HttpStatus int
	SharedData gin.H
}

func (*Context) ErrorMessage

func (c *Context) ErrorMessage(err error) Response

func (*Context) Fail

func (c *Context) Fail(code int, msg interface{}) Response

func (*Context) HTML

func (c *Context) HTML(name string, objs ...gin.H) Response

func (*Context) HTMLRender

func (c *Context) HTMLRender(file string, obj interface{}) template.HTML

func (*Context) JSON

func (c *Context) JSON(data interface{}) Response

func (*Context) Message

func (c *Context) Message(title, msg string) Response

func (*Context) Pagination

func (c *Context) Pagination(total int64, num, page int) *pagination.Paginater

func (*Context) Redirect

func (c *Context) Redirect(location string) Response

func (*Context) Session

func (c *Context) Session() sessions.Session

func (*Context) Status

func (c *Context) Status(status int)

func (*Context) String

func (c *Context) String(format string, values ...interface{}) Response

func (*Context) Success

func (c *Context) Success(data interface{}) Response

func (*Context) XML

func (c *Context) XML(data interface{}) Response

type HTMLProduction

type HTMLProduction struct{}

func (HTMLProduction) Instance

func (r HTMLProduction) Instance(name string, data interface{}) render.Render

type HTMLResponse

type HTMLResponse struct {
	HttpStatus int          `json:"-"`
	Context    *gin.Context `json:"-"`
	Name       string
	Data       interface{}
}

func (*HTMLResponse) Render

func (c *HTMLResponse) Render()

type HandlerFunc

type HandlerFunc func(c *Context) Response

func (HandlerFunc) Handle

func (h HandlerFunc) Handle(c *Context) Response

type IHandler

type IHandler interface {
	Handle(c *Context) Response
}

type JSONResponse

type JSONResponse struct {
	HttpStatus int          `json:"-"`
	Context    *gin.Context `json:"-"`
	Data       interface{}  `json:"data"`
}

func (*JSONResponse) Render

func (c *JSONResponse) Render()

type RedirectResponse

type RedirectResponse struct {
	HttpStatus int          `json:"-"`
	Context    *gin.Context `json:"-"`
	Location   string
}

func (*RedirectResponse) Render

func (c *RedirectResponse) Render()

type Response

type Response interface {
	Render()
}

type StringResponse

type StringResponse struct {
	HttpStatus int          `json:"-"`
	Context    *gin.Context `json:"-"`
	Name       string
	Data       []interface{}
}

func (*StringResponse) Render

func (c *StringResponse) Render()

type XMLResponse

type XMLResponse struct {
	HttpStatus int          `json:"-"`
	Context    *gin.Context `json:"-"`
	Data       interface{}  `json:"data"`
}

func (*XMLResponse) Render

func (c *XMLResponse) Render()

Jump to

Keyboard shortcuts

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