Documentation
¶
Index ¶
- Constants
- func ResponseBuffer(c IContext) error
- func StaticGz(dir string) func(c IContext) error
- type Action
- type ContextFactory
- type Filter
- type Filterer
- type Handler
- type IContext
- type JsonRpc
- type Logger
- type LogrusWrap
- func (l LogrusWrap) Debugf(format string, args ...interface{})
- func (l LogrusWrap) Errorf(format string, args ...interface{})
- func (l LogrusWrap) Fatalf(format string, args ...interface{})
- func (l LogrusWrap) Infof(format string, args ...interface{})
- func (l LogrusWrap) Warnf(format string, args ...interface{})
- func (l LogrusWrap) WithError(err error) Logger
- func (l LogrusWrap) WithTags(vals Tags) Logger
- type Maze
- func (m *Maze) Add(filters ...*Filter)
- func (m *Maze) DELETE(rule string, filters ...Handler)
- func (m *Maze) GET(rule string, filters ...Handler)
- func (m *Maze) ListenAndServe(addr string) error
- func (m *Maze) PATCH(rule string, filters ...Handler)
- func (m *Maze) POST(rule string, filters ...Handler)
- func (m *Maze) PUT(rule string, filters ...Handler)
- func (m *Maze) Push(rule string, filters ...Handler)
- func (m *Maze) PushMethod(methods []string, rule string, handlers ...Handler)
- func (m *Maze) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (m *Maze) Static(rule string, dir string)
- type MazeContext
- func (c *MazeContext) CurrentFilter() *Filter
- func (c *MazeContext) GetAttribute(key interface{}) interface{}
- func (c *MazeContext) GetRequest() *http.Request
- func (c *MazeContext) GetResponse() http.ResponseWriter
- func (c *MazeContext) JSON(status int, value interface{}) error
- func (c *MazeContext) Load(value interface{}) error
- func (c *MazeContext) Next(mc IContext) error
- func (c *MazeContext) PathValues() Values
- func (c *MazeContext) PathVars(value interface{}) error
- func (c *MazeContext) Payload(value interface{}) error
- func (c *MazeContext) Proceed() error
- func (c *MazeContext) QueryVars(value interface{}) error
- func (c *MazeContext) SetAttribute(key interface{}, value interface{})
- func (c *MazeContext) SetResponse(w http.ResponseWriter)
- func (c *MazeContext) TEXT(status int, value interface{}) error
- func (c *MazeContext) Values() Values
- func (c *MazeContext) Vars(value interface{}) error
- type Option
- type Sse
- type SseBroker
- type Tags
- type Values
- func (p Values) AsBool(k string) bool
- func (p Values) AsBools(k string) []bool
- func (p Values) AsFloat(k string) float64
- func (p Values) AsFloats(k string) []float64
- func (p Values) AsInt(k string) int64
- func (p Values) AsInts(k string) []int64
- func (p Values) AsString(k string) string
- func (p Values) AsStrings(k string) []string
- func (p Values) AsTime(k string) time.Time
- func (p Values) AsTimes(k string) []time.Time
- func (p Values) AsUint(k string) uint64
- func (p Values) AsUints(k string) []uint64
Constants ¶
const ( UNKNOWN_SRV = "JSONRPC01" UNKNOWN_ACT = "JSONRPC02" )
const ( WILDCARD = "*" WILDCARD_BEFORE = -1 WILDCARD_AFTER = 1 )
const ISO8601 = "2006-01-02T15:04:05.999999999Z0700"
Variables ¶
This section is empty.
Functions ¶
func ResponseBuffer ¶
ResponseBuffer buffers the response, permitting setting headers after starting writing the response.
Types ¶
type Action ¶
type Action struct {
// contains filtered or unexported fields
}
func (*Action) SetFilters ¶
type ContextFactory ¶
type IContext ¶
type IContext interface { Proceed() error GetResponse() http.ResponseWriter SetResponse(http.ResponseWriter) GetRequest() *http.Request GetAttribute(interface{}) interface{} SetAttribute(interface{}, interface{}) CurrentFilter() *Filter // Payload put the json string in the request body into the struct passed as an interface{} Payload(interface{}) error // PathVars put the path parameters in a url into the struct passed as an interface{} PathVars(interface{}) error // QueryVars put the parameters in the query part of a url into the struct passed as an interface{} QueryVars(interface{}) error // Vars Vars(interface{}) error // Values gets a path parameter converter PathValues() Values // Values gets a parameter converter (path + query) Values() Values // Load calls Vars and Payload Load(value interface{}) error // TEXT converts to string the interface{} value and sends it into the response with a status code TEXT(int, interface{}) error // JSON marshals the interface{} value into a json string and sends it into the response with a status code JSON(int, interface{}) error }
type JsonRpc ¶
type JsonRpc struct {
// contains filtered or unexported fields
}
func NewJsonRpc ¶
func (*JsonRpc) SetActionFilters ¶
func (*JsonRpc) SetFilters ¶
type LogrusWrap ¶
type LogrusWrap struct {
// contains filtered or unexported fields
}
func NewLogrus ¶
func NewLogrus(logger *logrus.Logger) LogrusWrap
func (LogrusWrap) Debugf ¶
func (l LogrusWrap) Debugf(format string, args ...interface{})
func (LogrusWrap) Errorf ¶
func (l LogrusWrap) Errorf(format string, args ...interface{})
func (LogrusWrap) Fatalf ¶
func (l LogrusWrap) Fatalf(format string, args ...interface{})
func (LogrusWrap) Infof ¶
func (l LogrusWrap) Infof(format string, args ...interface{})
func (LogrusWrap) Warnf ¶
func (l LogrusWrap) Warnf(format string, args ...interface{})
func (LogrusWrap) WithError ¶
func (l LogrusWrap) WithError(err error) Logger
func (LogrusWrap) WithTags ¶
func (l LogrusWrap) WithTags(vals Tags) Logger
type Maze ¶
type Maze struct {
// contains filtered or unexported fields
}
func (*Maze) ListenAndServe ¶
func (*Maze) PushMethod ¶
PushMethod adds the filters to the end of the last filters. If the current rule does NOT start with '/', the applied rule will be the concatenation of the last rule that started with '/' and ended with a '*' with this current one (the '*' is omitted). eg: /greet/* + sayHi/:Id = /greet/sayHi/:Id
type MazeContext ¶
type MazeContext struct { Response http.ResponseWriter Request *http.Request Attributes map[interface{}]interface{} // attributes only valid in this request // contains filtered or unexported fields }
func NewContext ¶
func NewContext(logger Logger, w http.ResponseWriter, r *http.Request, filters []*Filter) *MazeContext
func (*MazeContext) CurrentFilter ¶
func (c *MazeContext) CurrentFilter() *Filter
func (*MazeContext) GetAttribute ¶
func (c *MazeContext) GetAttribute(key interface{}) interface{}
func (*MazeContext) GetRequest ¶
func (c *MazeContext) GetRequest() *http.Request
func (*MazeContext) GetResponse ¶
func (c *MazeContext) GetResponse() http.ResponseWriter
func (*MazeContext) JSON ¶
func (c *MazeContext) JSON(status int, value interface{}) error
func (*MazeContext) Load ¶
func (c *MazeContext) Load(value interface{}) error
func (*MazeContext) Next ¶
func (c *MazeContext) Next(mc IContext) error
func (*MazeContext) PathValues ¶
func (c *MazeContext) PathValues() Values
func (*MazeContext) PathVars ¶
func (c *MazeContext) PathVars(value interface{}) error
PathVars put the path parameters in a url into the struct passed as an interface{}
func (*MazeContext) Payload ¶
func (c *MazeContext) Payload(value interface{}) error
func (*MazeContext) Proceed ¶
func (c *MazeContext) Proceed() error
Proceed proceeds to the next valid rule This method should be reimplemented in specialized Context, extending this one
func (*MazeContext) QueryVars ¶
func (c *MazeContext) QueryVars(value interface{}) error
QueryVars put the parameters in the query part of a url into the struct passed as an interface{}
func (*MazeContext) SetAttribute ¶
func (c *MazeContext) SetAttribute(key interface{}, value interface{})
func (*MazeContext) SetResponse ¶
func (c *MazeContext) SetResponse(w http.ResponseWriter)
func (*MazeContext) TEXT ¶
func (c *MazeContext) TEXT(status int, value interface{}) error
TEXT transforms value to text and send it as text content type with the specified status (eg: http.StatusOK)
func (*MazeContext) Values ¶
func (c *MazeContext) Values() Values
func (*MazeContext) Vars ¶
func (c *MazeContext) Vars(value interface{}) error
type Option ¶
type Option func(m *Maze)
func WithContextFactory ¶
func WithContextFactory(cf ContextFactory) Option
func WithLogger ¶
type SseBroker ¶
type SseBroker struct { sync.RWMutex OnConnect func() (Sse, error) // contains filtered or unexported fields }
func NewSseBroker ¶
func NewSseBroker() *SseBroker