appsrv

package
v2.1.16+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2018 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

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
)
View Source
const (
	HASH_ALG_MD5 int = iota
	HASH_ALG_SHA1
	HASH_ALG_SHA256
)

Variables

This section is empty.

Functions

func AppContextDB

func AppContextDB(ctx context.Context) *sql.DB

func Fetch

func Fetch(req *http.Request) ([]byte, error)

func FetchJSON

func FetchJSON(req *http.Request) (jsonutils.JSONObject, error)

func FetchStruct

func FetchStruct(req *http.Request, v interface{}) error

func PingHandler

func PingHandler(ctx context.Context, w http.ResponseWriter, r *http.Request)

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 SplitPath

func SplitPath(path string) []string

func StatisticHandler

func StatisticHandler(ctx context.Context, w http.ResponseWriter, r *http.Request)

func VersionHandler

func VersionHandler(ctx context.Context, w http.ResponseWriter, r *http.Request)

func WaitChannel

func WaitChannel(ch chan interface{}) interface{}

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 (app *Application) AddHandler2(method string, prefix string, handler func(context.Context, http.ResponseWriter, *http.Request), metadata map[string]interface{}, name string, tags map[string]string)

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) 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 Cache

type Cache struct {
	// contains filtered or unexported fields
}

func AppContextCache

func AppContextCache(ctx context.Context) *Cache

func NewCache

func NewCache(size uint32) *Cache

func (*Cache) AtomicGet

func (c *Cache) AtomicGet(key string) interface{}

func (*Cache) AtomicSet

func (c *Cache) AtomicSet(key string, val interface{})

func (*Cache) Get

func (c *Cache) Get(key string) interface{}

func (*Cache) Set

func (c *Cache) Set(key string, val interface{})

type Cors

type Cors struct {
	// Debug logger
	Log *log.Logger
	// contains filtered or unexported fields
}

Cors http handler

func NewCors

func NewCors(options CorsOptions) *Cors

New creates a new Cors handler with the provided options.

func (*Cors) Handler

func (c *Cors) Handler(h http.Handler) http.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 FilterHandler func(ctx context.Context, w http.ResponseWriter, r *http.Request)

type RadixNode

type RadixNode struct {
	// contains filtered or unexported fields
}

func NewRadix

func NewRadix() *RadixNode

func (*RadixNode) Add

func (r *RadixNode) Add(segments []string, data interface{}) error

func (*RadixNode) Match

func (r *RadixNode) Match(segments []string, params map[string]string) interface{}

func (*RadixNode) Segments

func (r *RadixNode) Segments() []string

func (*RadixNode) String

func (r *RadixNode) String() string

func (*RadixNode) Walk

func (r *RadixNode) Walk(f func(path string, data interface{}))

type Ring

type Ring struct {
	// contains filtered or unexported fields
}

func NewRing

func NewRing(size int) *Ring

func (*Ring) Capacity

func (r *Ring) Capacity() int

func (*Ring) Pop

func (r *Ring) Pop() interface{}

func (*Ring) Push

func (r *Ring) Push(val interface{}) bool

func (*Ring) Size

func (r *Ring) Size() int

type WorkerManager

type WorkerManager struct {
	// contains filtered or unexported fields
}

func NewWorkerManager

func NewWorkerManager(name string, workerCount int, backlog int) *WorkerManager

func (*WorkerManager) Run

func (wm *WorkerManager) Run(task func(), err chan interface{}) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL