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 (d *BuchatrestContext) String() string
- type Context
- func AddValuesToContext(ctx Context, values MapAny) Context
- func NewContext() Context
- func NewContextWithCancel(parent Context) (ctx Context, cancel context.CancelFunc)
- func NewContextWithDeadline(parent Context, d time.Time) (Context, context.CancelFunc)
- func NewContextWithOptions(options *ContextOptions) Context
- func NewContextWithTimeout(parent Context, timeout time.Duration) (Context, context.CancelFunc)
- func NewContextWithValue(parent Context, key, val interface{}) Context
- type ContextOptions
- type DefaultContext
- func (d *DefaultContext) Deadline() (deadline time.Time, ok bool)
- func (ctx *DefaultContext) Done() <-chan struct{}
- func (ctx *DefaultContext) ENV() ENV
- func (ctx *DefaultContext) Err() error
- func (ctx *DefaultContext) GORM() *gorm.DB
- func (ctx *DefaultContext) Log() *logrus.Logger
- func (ctx *DefaultContext) Redis() *redis.Client
- func (ctx *DefaultContext) SQL() *sql.DB
- func (ctx *DefaultContext) SQLX() *sqlx.DB
- func (d *DefaultContext) String() string
- func (ctx *DefaultContext) Value(key interface{}) interface{}
- type ENV
- type HTTPContext
- type HTTPError
- type HandlerFunc
- type HandlerFuncWithData
- type HandlersChain
- 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 ¶
type BuchatrestContext struct {
Context
// contains filtered or unexported fields
}
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) String ¶
func (d *BuchatrestContext) String() string
type Context ¶
type Context interface {
context.Context
ENV() ENV
GORM() *gorm.DB
Log() *logrus.Logger
Redis() *redis.Client
SQL() *sql.DB
SQLX() *sqlx.DB
}
func AddValuesToContext ¶
func NewContext ¶
func NewContext() Context
func NewContextWithCancel ¶
func NewContextWithCancel(parent Context) (ctx Context, cancel context.CancelFunc)
func NewContextWithDeadline ¶
func NewContextWithOptions ¶
func NewContextWithOptions(options *ContextOptions) Context
func NewContextWithTimeout ¶
func NewContextWithValue ¶
type ContextOptions ¶
type DefaultContext ¶
type DefaultContext struct{}
DefaultContext is basically just a mimic of context.Background It is a basic object that implement bucharest.Context and context.Context For original implementation please see context.Background()
func (*DefaultContext) Done ¶
func (ctx *DefaultContext) Done() <-chan struct{}
func (*DefaultContext) ENV ¶
func (ctx *DefaultContext) ENV() ENV
func (*DefaultContext) Err ¶
func (ctx *DefaultContext) Err() error
func (*DefaultContext) GORM ¶
func (ctx *DefaultContext) GORM() *gorm.DB
func (*DefaultContext) Log ¶
func (ctx *DefaultContext) Log() *logrus.Logger
func (*DefaultContext) Redis ¶
func (ctx *DefaultContext) Redis() *redis.Client
func (*DefaultContext) SQL ¶
func (ctx *DefaultContext) SQL() *sql.DB
func (*DefaultContext) SQLX ¶
func (ctx *DefaultContext) SQLX() *sqlx.DB
func (*DefaultContext) String ¶
func (d *DefaultContext) String() string
func (*DefaultContext) Value ¶
func (ctx *DefaultContext) Value(key interface{}) interface{}
type ENV ¶
type HTTPContext ¶
type HTTPContext interface {
Context
HandlerName() string
HandlerNames() []string
FullPath() string
Next()
IsAborted() bool
Abort()
AbortWithStatusJSON(code int, jsonObj interface{})
AbortWithStatus(code int)
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)
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)
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)
FormFile(name string) (*multipart.FileHeader, error)
MultipartForm() (*multipart.Form, error)
SaveUploadedFile(file *multipart.FileHeader, dst string) error
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)
ClientIP() string
RemoteIP() (net.IP, bool)
ContentType() string
IsWebsocket() bool
Status(code int)
Header(key, value string)
GetHeader(key string) string
GetRawData() ([]byte, error)
SetSameSite(samesite http.SameSite)
SetCookie(name, value string, maxAge int, path, domain string, secure, httpOnly bool)
Cookie(name string) (string, error)
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
SetAccepted(formats ...string)
GetGin() (*gin.Context, bool)
Gin() *gin.Context
// contains filtered or unexported methods
}
type HTTPError ¶
type HTTPError interface {
GetStatus() int
GetJSON() interface{}
}
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 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.