context

package
v0.0.0-...-e282ec7 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	APIContextKey = "ahfs-api-context-key"
)
View Source
var (
	ContextKey = "ahfs-context-key"
)

Functions

func APIContextWrapper

func APIContextWrapper(f func(c *APIContext)) gin.HandlerFunc

func APIContexter

func APIContexter() gin.HandlerFunc

func ContextWrapper

func ContextWrapper(f func(c *Context)) gin.HandlerFunc

func Contexter

func Contexter() gin.HandlerFunc

Types

type APIContext

type APIContext struct {
	*Context
}

func (*APIContext) Done

func (ctx *APIContext) Done(status int, data interface{})

func (*APIContext) Error

func (ctx *APIContext) Error(status int, code errcode.ErrorCode, obj interface{})

func (*APIContext) File

func (ctx *APIContext) File(filename string, localPath string)

func (*APIContext) InternalServerError

func (ctx *APIContext) InternalServerError(err error)

func (*APIContext) JSON

func (ctx *APIContext) JSON(status int, code errcode.ErrorCode, obj interface{})

func (*APIContext) NotFound

func (ctx *APIContext) NotFound(code errcode.ErrorCode, err error)

func (*APIContext) OK

func (ctx *APIContext) OK(data interface{})

func (*APIContext) Storage

func (ctx *APIContext) Storage(filename string, id storage.ID, fileStorage storage.Storage)

type APIError

type APIError struct {
	URL     string `json:"url"`
	Message string `json:"message"`
}

type APIHandlerFunc

type APIHandlerFunc func(*APIContext)

type APIResult

type APIResult struct {
	Code  errcode.ErrorCode `json:"code"`
	Data  interface{}       `json:"data,omitempty"`
	Error *APIError         `json:"error,omitempty"`
}

type Context

type Context struct {
	*gin.Context
	Session  sessions.Session
	Link     string
	User     *models.User
	IsSigned bool
}

func (*Context) HasValue

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

func (*Context) IsAdmin

func (ctx *Context) IsAdmin() bool

Jump to

Keyboard shortcuts

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