Documentation
¶
Index ¶
- Variables
- func NewGinHandlerFunc(ctx Context, handlerFunc HandlerFunc) gin.HandlerFunc
- func NewGinHandlerFuncWithData(ctx Context, handlerFunc HandlerFuncWithData, data Map) gin.HandlerFunc
- type BuchatrestContext
- func (ctx *BuchatrestContext) ENV() ENV
- func (ctx *BuchatrestContext) GORM() *gorm.DB
- func (ctx *BuchatrestContext) Log() *logrus.Logger
- func (ctx *BuchatrestContext) Redis() *redis.Client
- func (ctx *BuchatrestContext) SQL() *sql.DB
- func (ctx *BuchatrestContext) SQLX() *sqlx.DB
- func (ctx *BuchatrestContext) SetValue(key, val interface{})
- func (d *BuchatrestContext) String() string
- func (ctx *BuchatrestContext) Update(option *ContextOptions)
- type Context
- type ContextOptions
- type ENV
- type HTTPContext
- type HTTPError
- type HandlerFunc
- type HandlerFuncWithData
- type HandlersChain
- type HttpError
- type LogLevelFromGinParam
- type Map
- type MapAny
- type MockContext
- type ValidationErrors
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNoENV = errors.New("ENV is not present in this context")
View Source
var ErrNoGORM = errors.New("*gorm.DB is not present in this context")
View Source
var ErrNoLogrus = errors.New("*logrus.Logger is not present in this context")
View Source
var ErrNoRedis = errors.New("*redis.Client is not present in this context")
View Source
var ErrNoSQL = errors.New("*sql.DB is not present in this context")
View Source
var ErrNoSQLX = errors.New("*sqlx.DB is not present in this context")
Functions ¶
func NewGinHandlerFunc ¶
func NewGinHandlerFunc(ctx Context, handlerFunc HandlerFunc) gin.HandlerFunc
func NewGinHandlerFuncWithData ¶
func NewGinHandlerFuncWithData(ctx Context, handlerFunc HandlerFuncWithData, data Map) gin.HandlerFunc
Types ¶
type BuchatrestContext ¶
func (*BuchatrestContext) ENV ¶
func (ctx *BuchatrestContext) ENV() ENV
func (*BuchatrestContext) GORM ¶
func (ctx *BuchatrestContext) GORM() *gorm.DB
func (*BuchatrestContext) Log ¶
func (ctx *BuchatrestContext) Log() *logrus.Logger
func (*BuchatrestContext) Redis ¶
func (ctx *BuchatrestContext) Redis() *redis.Client
func (*BuchatrestContext) SQL ¶
func (ctx *BuchatrestContext) SQL() *sql.DB
func (*BuchatrestContext) SQLX ¶
func (ctx *BuchatrestContext) SQLX() *sqlx.DB
func (*BuchatrestContext) SetValue ¶ added in v0.1.1
func (ctx *BuchatrestContext) SetValue(key, val interface{})
func (*BuchatrestContext) String ¶
func (d *BuchatrestContext) String() string
func (*BuchatrestContext) Update ¶ added in v0.1.5
func (ctx *BuchatrestContext) Update(option *ContextOptions)
type Context ¶
type Context interface {
context.Context
ENV() ENV
GORM() *gorm.DB
Log() *logrus.Logger
Redis() *redis.Client
SQL() *sql.DB
SQLX() *sqlx.DB
SetValue(key, val interface{})
Update(option *ContextOptions)
}
func AddValuesToContext ¶
func NewContextWithOptions ¶
func NewContextWithOptions(options *ContextOptions) Context
type ContextOptions ¶
type ENV ¶
type HTTPContext ¶
type HTTPContext interface {
Context
// Handler info
HandlerName() string
HandlerNames() []string
// request
FullPath() string
ContentType() string
Cookie(name string) (string, error)
ClientIP() string
RemoteIP() (net.IP, bool)
GetHeader(key string) string
GetRawData() ([]byte, error)
IsWebsocket() bool
// handler control
Next()
IsAborted() bool
Abort()
AbortWithStatusJSON(code int, jsonObj interface{})
AbortWithStatus(code int)
// Setter and Getter
Get(key string) (interface{}, bool)
Set(key string, value interface{})
MustGet(key string) interface{}
GetString(key string) (s string)
GetBool(key string) (b bool)
GetInt(key string) (i int)
GetInt64(key string) (i64 int64)
GetUint(key string) (ui uint)
GetUint64(key string) (ui64 uint64)
GetFloat64(key string) (f64 float64)
GetTime(key string) (t time.Time)
GetDuration(key string) (d time.Duration)
GetStringSlice(key string) (ss []string)
GetStringMap(key string) (sm map[string]interface{})
GetStringMapString(key string) (sms map[string]string)
GetStringMapStringSlice(key string) (smss map[string][]string)
// parameter and query
Param(key string) string
Query(key string) string
DefaultQuery(key, defaultValue string) string
GetQuery(key string) (string, bool)
QueryArray(key string) []string
GetQueryArray(key string) ([]string, bool)
QueryMap(key string) map[string]string
GetQueryMap(key string) (map[string]string, bool)
// urlencoded
PostForm(key string) string
DefaultPostForm(key, defaultValue string) string
GetPostForm(key string) (string, bool)
PostFormArray(key string) []string
GetPostFormArray(key string) ([]string, bool)
PostFormMap(key string) map[string]string
GetPostFormMap(key string) (map[string]string, bool)
// multipart
FormFile(name string) (*multipart.FileHeader, error)
MultipartForm() (*multipart.Form, error)
SaveUploadedFile(file *multipart.FileHeader, dst string) error
// binder
Bind(obj interface{}) error
BindJSON(obj interface{}) error
BindXML(obj interface{}) error
BindQuery(obj interface{}) error
BindYAML(obj interface{}) error
BindHeader(obj interface{}) error
BindUri(obj interface{}) error
MustBindWith(obj interface{}, b binding.Binding) error
ShouldBind(obj interface{}) error
ShouldBindJSON(obj interface{}) error
ShouldBindXML(obj interface{}) error
ShouldBindQuery(obj interface{}) error
ShouldBindYAML(obj interface{}) error
ShouldBindHeader(obj interface{}) error
ShouldBindUri(obj interface{}) error
ShouldBindWith(obj interface{}, b binding.Binding) error
ShouldBindBodyWith(obj interface{}, bb binding.BindingBody) (err error)
// response header
Status(code int)
Header(key, value string)
SetSameSite(samesite http.SameSite)
SetCookie(name, value string, maxAge int, path, domain string, secure, httpOnly bool)
SetAccepted(formats ...string)
// response body
Render(code int, r render.Render)
HTML(code int, name string, obj interface{})
IndentedJSON(code int, obj interface{})
SecureJSON(code int, obj interface{})
JSONP(code int, obj interface{})
JSON(code int, obj interface{})
AsciiJSON(code int, obj interface{})
PureJSON(code int, obj interface{})
XML(code int, obj interface{})
YAML(code int, obj interface{})
ProtoBuf(code int, obj interface{})
String(code int, format string, values ...interface{})
Redirect(code int, location string)
Data(code int, contentType string, data []byte)
DataFromReader(code int, contentLength int64, contentType string, reader io.Reader, extraHeaders map[string]string)
File(filepath string)
FileFromFS(filepath string, fs http.FileSystem)
FileAttachment(filepath, filename string)
SSEvent(name string, message interface{})
Stream(step func(w io.Writer) bool) bool
GetGin() (*gin.Context, bool)
Gin() *gin.Context
// contains filtered or unexported methods
}
type HTTPError ¶
func GinLoggerWithConfig ¶
func GinLoggerWithConfig(ctx HTTPContext, data Map) HTTPError
func NewBadRequestError ¶
func NewInternalServerError ¶
type HandlerFunc ¶
type HandlerFunc func(HTTPContext) HTTPError
type HandlerFuncWithData ¶
type HandlerFuncWithData func(HTTPContext, Map) HTTPError
type HandlersChain ¶
type HandlersChain []HandlerFunc
type HttpError ¶ added in v0.1.1
type HttpError struct {
Message interface{} `json:"message"`
// contains filtered or unexported fields
}
func (*HttpError) OriginalError ¶ added in v0.1.1
type LogLevelFromGinParam ¶ added in v0.0.3
type LogLevelFromGinParam func(*gin.LogFormatterParams) logrus.Level
type MockContext ¶
func NewMockContext ¶
func NewMockContext(parentContext Context, mock sqlmock.Sqlmock) MockContext
type ValidationErrors ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.