router

package
v0.0.0-...-7d7277e Latest Latest
Warning

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

Go to latest
Published: May 1, 2018 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Any int = iota
	Text
	Int
	I32
	I64
	U32
	U64
	F32
	F64
	Bool
	Lat
	Lon
	Json
	Email
	URL
	UUID
	File
	DateTimeRFC822
	DateTimeRFC3339
	DateTimeUnix
)

Variables

View Source
var RequestContext = key("request-context")

RequestContext key

Functions

func Val

func Val(typ int, v []byte) (interface{}, bool)

Types

type CacheAdaptor

type CacheAdaptor interface {
	Set(key []byte, data []byte, ttl time.Duration) error
	Get(key []byte) ([]byte, error)
}

CacheAdaptor interface

type Client

type Client interface {
	IP() string
	Host() string
	Device() Device
	Protocol() string
}

Client interface

type Context

type Context interface {
	Deadline() (time.Time, bool)
	Done() <-chan struct{}
	Err() error
	Value(interface{}) interface{}
	Identity() Identity
	MachineID() string
	ProcessID() string
	Context() context.Context
	Req() *http.Request
	Res() http.ResponseWriter
	Client() Client
	Cache() CacheAdaptor
	Message() MessageAdaptor
	GQLSubscription() GQLSubscriptionAdaptor
	DataLoader(interface{}) DataLoaderAdaptor
	KV() KV
	Cookie() Cookie
	Header() Header
	MustParam(s string) Value
	MustQuery(s string) Value
	MustBody(s string) Value
	Param(s string) (Value, error)
	Query(s string) (Value, error)
	Body(s string) (Value, error)
	File(s string) []byte
	StartSpan(operationName string, opts ...opentracing.StartSpanOption) opentracing.Span
	Tracer() opentracing.Tracer
	Recover() error
	Abort()
	IsAborted() bool
	Proto(ProtoMessage) Context
	Write(b []byte) Context
	Error(error) Context
	Json(o interface{}) Context
	Status(code int) Context
	Child() Context
}

Context interface

type Cookie interface {
	Set(key string, val string, opts ...cookie.Option)
	Get(key string) (Value, error)
	MustGet(key string) Value
}

Cookie interface

type CustomFunc

type CustomFunc func(v []byte) bool

CustomFunc type

type DataLoaderAdaptor

type DataLoaderAdaptor interface {
	Load(context.Context, interface{}) (interface{}, error)
	LoadMany(context.Context, []interface{}) ([]interface{}, []error)
	Clear(interface{})
	ClearAll()
	Prime(interface{}, interface{})
}

DataLoaderAdaptor interface

type Device

type Device interface {
	Useragent() Useragent
	Hardware() Hardware
	OS() OS
}

Device interface

type GQLEvent

type GQLEvent interface {
	Field() string
	Payload() []byte
	Filters() map[string]interface{}
	EqIDs() []int64
	NeIDs() []int64
	EqKeys() []string
	NeKeys() []string
	Strict() bool
}

GQLEvent interface

type GQLSubscriptionAdaptor

type GQLSubscriptionAdaptor interface {
	Emit(GQLEvent) error
}

GQLSubscriptionAdaptor interface

type HandlerFunc

type HandlerFunc func(Context)

HandlerFunc type

type HandlerFuncs

type HandlerFuncs []HandlerFunc

HandlerFuncs type

type Hardware

type Hardware interface {
	Family() string
	Brand() string
	Model() string
}

Hardware interface

type Header interface {
	Set(key string, val string)
	Get(key string) (Value, error)
	MustGet(key string) Value
}

Header interface

type Identity

type Identity interface {
	HasID() bool
	GetID() int
	SetID(int)
	HasKey() bool
	GetKey() string
	SetKey(string)
}

Identity interface

type KV

type KV interface {
	Set(string, []byte) KV
	Get(string) []byte
}

KV key value interface

type MessageAdaptor

type MessageAdaptor interface {
	Emit([]byte, []byte) error
	Listen([]byte, message.Handler) message.Close
}

MessageAdaptor broker interface

type Model

type Model interface {
	Code() int
	Hash() string
}

Model interface

type OS

type OS interface {
	Family() string
	Major() string
	Minor() string
	Patch() string
}

OS interface

type Option

type Option func(*Options)

Option func

func ID

func ID(s string) Option

ID to change server reference id

type Options

type Options struct {

	// engine server unique id
	ID string
}

Options is the engine server options

type Param

type Param interface {
	Custom(CustomFunc) Param
	Format(int) Param
	Summary(string) Param
	Doc(string) Param
	Default([]byte) Param
	Require(bool) Param
	DependsOn(...Param) Param
	Config() ParamConfig
}

Param interface

type ParamConfig

type ParamConfig interface {
	Name() string
	Type() ParamType
	Custom() CustomFunc
	Format() int
	Summary() string
	Doc() string
	Default() []byte
	Require() bool
	DependsOn() []Param
	OneOf() []Param
}

ParamConfig interface

type ParamType

type ParamType int

ParamType type

const (
	UnknownParam ParamType = iota
	ParamBody
	ParamParam
	ParamQuery
	ParamHeader
	ParamCookie
	ParamOneOf
)

UnknownType type

func (ParamType) String

func (v ParamType) String() string

String value for ParamType

type ProtoMessage

type ProtoMessage interface {
	Reset()
	String() string
	ProtoMessage()
}

ProtoMessage message interface

type Route

type Route interface {
	Get(string) Route
	Head(string) Route
	Options(string) Route
	Post(string) Route
	Put(string) Route
	Patch(string) Route
	Delete(string) Route
	Namespace(string) Route
	Alias(...string) Route
	Name(string) Route
	Summary(string) Route
	Doc(string) Route
	Params(...Param) Route
	ClearParams() Route
	MaxMemory(int64) Route
	Handle(HandlerFunc) Route
	Catch(HandlerFunc) Route
	Middleware(...HandlerFunc) Route
	ClearMiddleware() Route
	Websocket(bool) Route
	HTTP(bool) Route
	Models(...Model) Route
	Config() RouteConfig
}

Route interface

type RouteConfig

type RouteConfig interface {
	Pattern() string
	Aliases() []string
	Method() string
	Name() string
	Summary() string
	Doc() string
	Namespace() bool
	Websocket() bool
	HTTP() bool
	Params() []Param
	ValueIndex(Param) int
	MaxMemory() int64
	Routes() []Route
	Handler() HandlerFunc
	Catch() HandlerFunc
	Middlewares() HandlerFuncs
	Model(int) interface{}
}

RouteConfig interface

type Service

type Service interface {
	Start() error
	Stop() error
	Get(string) Route
	Head(string) Route
	Options(string) Route
	Post(string) Route
	Put(string) Route
	Patch(string) Route
	Delete(string) Route
	Namespace(string) Route
	NotFound(HandlerFunc) Service
	MethodNotAllowed(HandlerFunc) Service
	Params(...Param) Service
	Middleware(...HandlerFunc) Service
	RouteNotFound() HandlerFunc
	RouteNotAllowed() HandlerFunc
	Routes() []Route
	String() string
}

Service interface

func New

func New(opts ...Option) Service

New creates engine server

type Useragent

type Useragent interface {
	Family() string
	Major() string
	Minor() string
	Patch() string
	String() string
}

Useragent interface

type Value

type Value interface {
	Key() string
	Val() []byte
	Has() bool
	MustInt() int
	MustI32() int32
	MustI64() int64
	MustU32() uint32
	MustU64() uint64
	MustF32() float32
	MustF64() float64
	MustBool() bool
	MustTime() time.Time
	String() string
}

Value interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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