Documentation ¶
Index ¶
- Constants
- func AppContextDB(ctx context.Context) *sql.DB
- func Fetch(req *http.Request) ([]byte, error)
- func FetchJSON(req *http.Request) (jsonutils.JSONObject, error)
- func FetchStruct(req *http.Request, v interface{}) error
- func PingHandler(ctx context.Context, w http.ResponseWriter, r *http.Request)
- func Send(w http.ResponseWriter, text string)
- func SendJSON(w http.ResponseWriter, obj jsonutils.JSONObject)
- func SendStruct(w http.ResponseWriter, obj interface{})
- func SplitPath(path string) []string
- func StatisticHandler(ctx context.Context, w http.ResponseWriter, r *http.Request)
- func VersionHandler(ctx context.Context, w http.ResponseWriter, r *http.Request)
- func WaitChannel(ch chan interface{}) interface{}
- func WorkerStatsHandler(ctx context.Context, w http.ResponseWriter, r *http.Request)
- type Application
- func (app *Application) AddHandler(method string, prefix string, ...)
- func (app *Application) AddHandler2(method string, prefix string, ...)
- func (app *Application) AddHandler3(hi *SHandlerInfo)
- func (app *Application) AddReverseProxyHandler(prefix string, ef *proxy.SEndpointFactory)
- func (app *Application) CORSAllowAll()
- func (app *Application) CORSAllowHosts(hosts []string)
- func (app *Application) EnableCORS(options CorsOptions)
- func (app *Application) GetName() string
- func (app *Application) ListenAndServe(addr string)
- func (app *Application) ListenAndServeTLS(addr string, certFile, keyFile string)
- func (app *Application) RegisterMiddleware(f MiddlewareFunc)
- func (app *Application) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (app *Application) SetContext(key appctx.AppContextKey, val interface{})
- type Cache
- type Cors
- type CorsOptions
- type FilterHandler
- type MiddlewareFunc
- type RadixNode
- type Ring
- type SHandlerInfo
- func (this *SHandlerInfo) GetName(params map[string]string) string
- func (this *SHandlerInfo) GetTags() map[string]string
- func (hi *SHandlerInfo) SetHandler(hand func(context.Context, http.ResponseWriter, *http.Request)) *SHandlerInfo
- func (hi *SHandlerInfo) SetMetadata(meta map[string]interface{}) *SHandlerInfo
- func (hi *SHandlerInfo) SetMethod(method string) *SHandlerInfo
- func (hi *SHandlerInfo) SetName(name string) *SHandlerInfo
- func (hi *SHandlerInfo) SetPath(path string) *SHandlerInfo
- func (hi *SHandlerInfo) SetProcessTimeout(to time.Duration) *SHandlerInfo
- func (hi *SHandlerInfo) SetTags(tags map[string]string) *SHandlerInfo
- func (hi *SHandlerInfo) SetWorkerManager(workerMan *SWorkerManager) *SHandlerInfo
- type SWorker
- type SWorkerList
- type SWorkerManager
- type SWorkerManagerStates
Constants ¶
View Source
const ( DEFAULT_BACKLOG = 256 DEFAULT_IDLE_TIMEOUT = 10 * time.Second DEFAULT_READ_TIMEOUT = 0 DEFAULT_READ_HEADER_TIMEOUT = 10 * time.Second DEFAULT_WRITE_TIMEOUT = 0 DEFAULT_PROCESS_TIMEOUT = 15 * time.Second )
View Source
const ( HASH_ALG_MD5 int = iota HASH_ALG_SHA1 HASH_ALG_SHA256 )
View Source
const ( WORKER_STATE_ACTIVE = 0 WORKER_STATE_DETACH = 1 )
Variables ¶
This section is empty.
Functions ¶
func FetchStruct ¶
func PingHandler ¶
func Send ¶
func Send(w http.ResponseWriter, text string)
func SendJSON ¶
func SendJSON(w http.ResponseWriter, obj jsonutils.JSONObject)
func SendStruct ¶
func SendStruct(w http.ResponseWriter, obj interface{})
func StatisticHandler ¶
func VersionHandler ¶
func WaitChannel ¶
func WaitChannel(ch chan interface{}) interface{}
func WorkerStatsHandler ¶
Types ¶
type Application ¶
type Application struct {
// contains filtered or unexported fields
}
func AppContextApp ¶
func AppContextApp(ctx context.Context) *Application
func NewApplication ¶
func NewApplication(name string, connMax int) *Application
func (*Application) AddHandler ¶
func (app *Application) AddHandler(method string, prefix string, handler func(context.Context, http.ResponseWriter, *http.Request))
func (*Application) AddHandler2 ¶
func (*Application) AddHandler3 ¶
func (app *Application) AddHandler3(hi *SHandlerInfo)
func (*Application) AddReverseProxyHandler ¶
func (app *Application) AddReverseProxyHandler(prefix string, ef *proxy.SEndpointFactory)
func (*Application) CORSAllowAll ¶
func (app *Application) CORSAllowAll()
func (*Application) CORSAllowHosts ¶
func (app *Application) CORSAllowHosts(hosts []string)
func (*Application) EnableCORS ¶
func (app *Application) EnableCORS(options CorsOptions)
func (*Application) GetName ¶
func (app *Application) GetName() string
func (*Application) ListenAndServe ¶
func (app *Application) ListenAndServe(addr string)
func (*Application) ListenAndServeTLS ¶
func (app *Application) ListenAndServeTLS(addr string, certFile, keyFile string)
func (*Application) RegisterMiddleware ¶
func (app *Application) RegisterMiddleware(f MiddlewareFunc)
func (*Application) ServeHTTP ¶
func (app *Application) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*Application) SetContext ¶
func (app *Application) SetContext(key appctx.AppContextKey, val interface{})
type Cors ¶
Cors http handler
func NewCors ¶
func NewCors(options CorsOptions) *Cors
New creates a new Cors handler with the provided options.
func (*Cors) Handler ¶
Handler apply the CORS specification on the request, and add relevant CORS headers as necessary.
func (*Cors) HandlerFunc ¶
func (c *Cors) HandlerFunc(w http.ResponseWriter, r *http.Request)
HandlerFunc provides Martini compatible handler
func (*Cors) ServeHTTP ¶
func (c *Cors) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
Negroni compatible interface
type CorsOptions ¶
type CorsOptions struct { // AllowedOrigins is a list of origins a cross-domain request can be executed from. // If the special "*" value is present in the list, all origins will be allowed. // An origin may contain a wildcard (*) to replace 0 or more characters // (i.e.: http://*.domain.com). Usage of wildcards implies a small performance penalty. // Only one wildcard can be used per origin. // Default value is ["*"] AllowedOrigins []string // AllowOriginFunc is a custom function to validate the origin. It take the origin // as argument and returns true if allowed or false otherwise. If this option is // set, the content of AllowedOrigins is ignored. AllowOriginFunc func(origin string) bool // AllowedMethods is a list of methods the client is allowed to use with // cross-domain requests. Default value is simple methods (HEAD, GET and POST). AllowedMethods []string // AllowedHeaders is list of non simple headers the client is allowed to use with // cross-domain requests. // If the special "*" value is present in the list, all headers will be allowed. // Default value is [] but "Origin" is always appended to the list. AllowedHeaders []string // ExposedHeaders indicates which headers are safe to expose to the API of a CORS // API specification ExposedHeaders []string // AllowCredentials indicates whether the request can include user credentials like // cookies, HTTP authentication or client side SSL certificates. AllowCredentials bool // MaxAge indicates how long (in seconds) the results of a preflight request // can be cached MaxAge int // Debugging flag adds additional output to debug server side CORS issues Debug bool }
Options is a configuration container to setup the CORS middleware.
type FilterHandler ¶
type MiddlewareFunc ¶
type RadixNode ¶
type RadixNode struct {
// contains filtered or unexported fields
}
type SHandlerInfo ¶
type SHandlerInfo struct {
// contains filtered or unexported fields
}
func (*SHandlerInfo) GetTags ¶
func (this *SHandlerInfo) GetTags() map[string]string
func (*SHandlerInfo) SetHandler ¶
func (hi *SHandlerInfo) SetHandler(hand func(context.Context, http.ResponseWriter, *http.Request)) *SHandlerInfo
func (*SHandlerInfo) SetMetadata ¶
func (hi *SHandlerInfo) SetMetadata(meta map[string]interface{}) *SHandlerInfo
func (*SHandlerInfo) SetMethod ¶
func (hi *SHandlerInfo) SetMethod(method string) *SHandlerInfo
func (*SHandlerInfo) SetName ¶
func (hi *SHandlerInfo) SetName(name string) *SHandlerInfo
func (*SHandlerInfo) SetPath ¶
func (hi *SHandlerInfo) SetPath(path string) *SHandlerInfo
func (*SHandlerInfo) SetProcessTimeout ¶
func (hi *SHandlerInfo) SetProcessTimeout(to time.Duration) *SHandlerInfo
func (*SHandlerInfo) SetTags ¶
func (hi *SHandlerInfo) SetTags(tags map[string]string) *SHandlerInfo
func (*SHandlerInfo) SetWorkerManager ¶
func (hi *SHandlerInfo) SetWorkerManager(workerMan *SWorkerManager) *SHandlerInfo
type SWorkerList ¶
type SWorkerList struct {
// contains filtered or unexported fields
}
type SWorkerManager ¶
type SWorkerManager struct {
// contains filtered or unexported fields
}
func NewWorkerManager ¶
func NewWorkerManager(name string, workerCount int, backlog int) *SWorkerManager
func (*SWorkerManager) ActiveWorkerCount ¶
func (wm *SWorkerManager) ActiveWorkerCount() int
func (*SWorkerManager) DetachedWorkerCount ¶
func (wm *SWorkerManager) DetachedWorkerCount() int
func (*SWorkerManager) Run ¶
func (wm *SWorkerManager) Run(task func(), worker chan *SWorker, err chan interface{}) bool
Source Files ¶
Click to show internal directories.
Click to hide internal directories.