Documentation
¶
Index ¶
- Constants
- func GetDataContext(c *gin.Context) (context.IDataMap, bool)
- func SetDataContext(c *gin.Context, key string, val interface{})
- func WithDataContext() func(*gin.Context)
- type CRUDMiddleware
- type CRUDQMiddleware
- type MiddlewareTypeEnum
- type TorpedoMiddleware
- func WithCreateMiddleware(fn gin.HandlerFunc) *TorpedoMiddleware
- func WithDeleteMiddleware(fn gin.HandlerFunc) *TorpedoMiddleware
- func WithQueryMiddleware(fn gin.HandlerFunc) *TorpedoMiddleware
- func WithReadMiddleware(fn gin.HandlerFunc) *TorpedoMiddleware
- func WithUpdateMiddleware(fn gin.HandlerFunc) *TorpedoMiddleware
Constants ¶
const (
KeyDataContext = "TORPEDO_DATA_CONTEXT"
)
Variables ¶
This section is empty.
Functions ¶
func GetDataContext ¶ added in v0.4.0
GetDataContext returns the request context.DataMap and a boolean to check if it exists. If the data map has not been set a context.NoOpDataMap is returned instead
func SetDataContext ¶ added in v0.4.0
SetDataContext sets a key-value pair into the DataContext map.
func WithDataContext ¶ added in v0.4.0
WithDataContext sets a context.DataMap as context application useful to share data within request execution flow.
Types ¶
type CRUDMiddleware ¶
type CRUDMiddleware struct { Create []gin.HandlerFunc Read []gin.HandlerFunc Update []gin.HandlerFunc Delete []gin.HandlerFunc }
CRUDMiddleware contains all the given CRUD middlewares
func NewCRUDMiddleware ¶
func NewCRUDMiddleware() *CRUDMiddleware
NewCRUDMiddleware constructor of CRUDMiddleware
func ToCRUDMiddlewares ¶
func ToCRUDMiddlewares(mm ...*TorpedoMiddleware) *CRUDMiddleware
ToCRUDMiddlewares given a list of TorpedoMiddleware creates and returns the CRUDMiddleware instance
func (*CRUDMiddleware) HasCreate ¶
func (m *CRUDMiddleware) HasCreate() bool
HasCreate check if the Create middleware list is empty or not
func (*CRUDMiddleware) HasDelete ¶
func (m *CRUDMiddleware) HasDelete() bool
HasDelete check if the Delete middleware list is empty or not
func (*CRUDMiddleware) HasRead ¶
func (m *CRUDMiddleware) HasRead() bool
HasRead check if the Read middleware list is empty or not
func (*CRUDMiddleware) HasUpdate ¶
func (m *CRUDMiddleware) HasUpdate() bool
HasUpdate check if the Update middleware list is empty or not
type CRUDQMiddleware ¶ added in v0.3.5
type CRUDQMiddleware struct { CRUDMiddleware Query []gin.HandlerFunc }
CRUDQMiddleware extends the CRUDMiddleware to support the Query middleware as well
func NewCRUDQMiddleware ¶ added in v0.3.5
func NewCRUDQMiddleware() *CRUDQMiddleware
NewCRUDQMiddleware constructor of CRUDQMiddleware
func ToCRUDQMiddlewares ¶ added in v0.3.5
func ToCRUDQMiddlewares(mm ...*TorpedoMiddleware) *CRUDQMiddleware
ToCRUDQMiddlewares given a list of TorpedoMiddleware creates and returns the CRUDQMiddleware instance
func (*CRUDQMiddleware) HasQuery ¶ added in v0.3.5
func (m *CRUDQMiddleware) HasQuery() bool
HasQuery check if the Query middleware list is empty or not
type MiddlewareTypeEnum ¶
const ( Undefined MiddlewareTypeEnum = iota Create Read Update Delete Query )
func NewMiddlewareTypeEnumFromString ¶
func NewMiddlewareTypeEnumFromString(s string) MiddlewareTypeEnum
func (MiddlewareTypeEnum) String ¶
func (c MiddlewareTypeEnum) String() string
func (MiddlewareTypeEnum) ToInt ¶
func (c MiddlewareTypeEnum) ToInt() int
func (MiddlewareTypeEnum) Value ¶
func (c MiddlewareTypeEnum) Value() enum.Type
type TorpedoMiddleware ¶
type TorpedoMiddleware struct { Type MiddlewareTypeEnum Fn gin.HandlerFunc }
TorpedoMiddleware struct to create middlewares via parameter
func WithCreateMiddleware ¶
func WithCreateMiddleware(fn gin.HandlerFunc) *TorpedoMiddleware
WithCreateMiddleware attach the given middleware to the Create request
func WithDeleteMiddleware ¶
func WithDeleteMiddleware(fn gin.HandlerFunc) *TorpedoMiddleware
WithDeleteMiddleware attach the given middleware to the Delete request
func WithQueryMiddleware ¶ added in v0.3.5
func WithQueryMiddleware(fn gin.HandlerFunc) *TorpedoMiddleware
WithQueryMiddleware attach the given middleware to the Query request
func WithReadMiddleware ¶
func WithReadMiddleware(fn gin.HandlerFunc) *TorpedoMiddleware
WithReadMiddleware attach the given middleware to the Read request
func WithUpdateMiddleware ¶
func WithUpdateMiddleware(fn gin.HandlerFunc) *TorpedoMiddleware
WithUpdateMiddleware attach the given middleware to the Update request