Documentation
¶
Index ¶
- Constants
- func NotFoundMiddleware(ctx HTTPContext)
- type Cors
- type Flow
- type FlowBuilder
- func (fb *FlowBuilder) Build() *Flow
- func (fb *FlowBuilder) DELETE(path string, handler func(ctx HTTPContext))
- func (fb *FlowBuilder) GET(path string, handler func(ctx HTTPContext))
- func (fb *FlowBuilder) HEAD(path string, handler func(ctx HTTPContext))
- func (fb *FlowBuilder) Map(path string, handler func(ctx HTTPContext), methods ...HTTPMethod)
- func (fb *FlowBuilder) OPTIONS(path string, handler func(ctx HTTPContext))
- func (fb *FlowBuilder) POST(path string, handler func(ctx HTTPContext))
- func (fb *FlowBuilder) PUT(path string, handler func(ctx HTTPContext))
- func (fb *FlowBuilder) Run(middleware func(ctx HTTPContext))
- func (fb *FlowBuilder) RunPost(middleware func(ctx HTTPContext))
- func (fb *FlowBuilder) SetHTTPDispatcher(hd HTTPRequestDispatcher)
- func (fb *FlowBuilder) SetNotFound(nf func(ctx HTTPContext))
- func (fb *FlowBuilder) SetResource(key string, value interface{})
- func (fb *FlowBuilder) SetResourceAlsoWithType(key string, value interface{})
- func (fb *FlowBuilder) SetResourceWithType(key reflect.Type, value interface{})
- func (fb *FlowBuilder) TRACE(path string, handler func(ctx HTTPContext))
- func (fb *FlowBuilder) Use(middleware func(ctx HTTPContext, next func()))
- func (fb *FlowBuilder) UseCors(origins []string, methods []string, headers []string, expose []string)
- func (fb *FlowBuilder) UsePost(middleware func(ctx HTTPContext, next func()))
- type HTTPContext
- type HTTPMethod
- type HTTPRequestDispatcher
Constants ¶
const ( // HTTPGet GET HTTPGet = iota // HTTPHead HEAD HTTPHead // HTTPPost POST HTTPPost // HTTPPut PUT HTTPPut // HTTPDelete DELETE HTTPDelete // HTTPOptions OPTIONS HTTPOptions // HTTPTrace TRACE HTTPTrace )
Variables ¶
This section is empty.
Functions ¶
func NotFoundMiddleware ¶
func NotFoundMiddleware(ctx HTTPContext)
NotFoundMiddleware handles not found case
Types ¶
type Cors ¶
type Cors struct { AllowedOrigins map[string]bool AllowedMethods []string AllowedHeaders []string ExposedHeaders []string }
Cors is used to handle CORS
type Flow ¶
type Flow struct {
// contains filtered or unexported fields
}
Flow is main service register center
func (*Flow) GetResource ¶
GetResource gets global singleton resource preset
func (*Flow) GetResourceByType ¶
GetResourceByType gets global singleton resource preset by type
type FlowBuilder ¶
type FlowBuilder struct {
// contains filtered or unexported fields
}
func NewBuilder ¶
func NewBuilder() *FlowBuilder
func (*FlowBuilder) DELETE ¶
func (fb *FlowBuilder) DELETE(path string, handler func(ctx HTTPContext))
func (*FlowBuilder) GET ¶
func (fb *FlowBuilder) GET(path string, handler func(ctx HTTPContext))
func (*FlowBuilder) HEAD ¶
func (fb *FlowBuilder) HEAD(path string, handler func(ctx HTTPContext))
func (*FlowBuilder) Map ¶
func (fb *FlowBuilder) Map(path string, handler func(ctx HTTPContext), methods ...HTTPMethod)
Map is used to add request handler
func (*FlowBuilder) OPTIONS ¶
func (fb *FlowBuilder) OPTIONS(path string, handler func(ctx HTTPContext))
func (*FlowBuilder) POST ¶
func (fb *FlowBuilder) POST(path string, handler func(ctx HTTPContext))
func (*FlowBuilder) PUT ¶
func (fb *FlowBuilder) PUT(path string, handler func(ctx HTTPContext))
func (*FlowBuilder) Run ¶
func (fb *FlowBuilder) Run(middleware func(ctx HTTPContext))
Run runnable typed middleware will always invoke next
func (*FlowBuilder) RunPost ¶
func (fb *FlowBuilder) RunPost(middleware func(ctx HTTPContext))
RunPost add middleware must be invoked after HTTP request dispatcher
func (*FlowBuilder) SetHTTPDispatcher ¶
func (fb *FlowBuilder) SetHTTPDispatcher(hd HTTPRequestDispatcher)
SetHTTPDispatcher replaces default HTTP request handler. It can be nil.
func (*FlowBuilder) SetNotFound ¶
func (fb *FlowBuilder) SetNotFound(nf func(ctx HTTPContext))
SetNotFound replaces the default not found middleware
func (*FlowBuilder) SetResource ¶
func (fb *FlowBuilder) SetResource(key string, value interface{})
SetResource sets global singleton resource
func (*FlowBuilder) SetResourceAlsoWithType ¶
func (fb *FlowBuilder) SetResourceAlsoWithType(key string, value interface{})
SetResourceAlsoWithType calls SetResource and SetResourceWithType
func (*FlowBuilder) SetResourceWithType ¶
func (fb *FlowBuilder) SetResourceWithType(key reflect.Type, value interface{})
SetResourceWithType sets global singleton resource using it's type as key
func (*FlowBuilder) TRACE ¶
func (fb *FlowBuilder) TRACE(path string, handler func(ctx HTTPContext))
func (*FlowBuilder) Use ¶
func (fb *FlowBuilder) Use(middleware func(ctx HTTPContext, next func()))
Use registers middleware
func (*FlowBuilder) UseCors ¶
func (fb *FlowBuilder) UseCors(origins []string, methods []string, headers []string, expose []string)
UseCors registers CORS middleware
func (*FlowBuilder) UsePost ¶
func (fb *FlowBuilder) UsePost(middleware func(ctx HTTPContext, next func()))
UsePost add middleware to invoke after HTTP request dispatcher
type HTTPContext ¶
type HTTPContext struct { Request *http.Request ResponseWriter http.ResponseWriter Vars map[string]string Props map[string]interface{} // contains filtered or unexported fields }
HTTPContext is the request context wrapper
func (HTTPContext) GetResource ¶
func (ctx HTTPContext) GetResource(key string) interface{}
GetResource gets global singleton resource preset
func (HTTPContext) GetResourceByType ¶
func (ctx HTTPContext) GetResourceByType(key reflect.Type) interface{}
GetResourceByType gets global singleton resource preset by type
type HTTPRequestDispatcher ¶
type HTTPRequestDispatcher interface { Map(path string, handler func(ctx HTTPContext), methods ...HTTPMethod) Handle(ctx HTTPContext) }