api

package
v0.0.0-...-38decf1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2018 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// MethodGet GET
	MethodGet = "GET"

	// MethodPost POST
	MethodPost = "POST"

	// MethodPut PUT
	MethodPut = "PUT"

	// MethodPatch PATCH
	MethodPatch = "PATCH"

	// MethodDelete DELETE
	MethodDelete = "DELETE"

	// MethodHead HEAD
	MethodHead = "HEAD"

	// MethodOptions OPTIONS
	MethodOptions = "OPTIONS"
)
View Source
var (

	// ErrBadName bad API service name
	ErrBadName = errors.New("Bad API service name")
)

Functions

func AddFilter

func AddFilter(f Filter)

AddFilter add filter

func AddFilterExecutor

func AddFilterExecutor(fe FilterExecutor)

AddFilterExecutor add filter executor directly

func AddService

func AddService(s Service)

AddService add service to API

func Init

func Init(service web.Service, z Initializer) error

Init API server

Types

type Dispatcher

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

Dispatcher for API

func NewDispatcher

func NewDispatcher() *Dispatcher

NewDispatcher create new dispatcher

func (*Dispatcher) AddError

func (d *Dispatcher) AddError(e *eerr.Error)

AddError add error

func (*Dispatcher) AddResult

func (d *Dispatcher) AddResult(key, value string)

AddResult add result

func (*Dispatcher) Dispatch

func (d *Dispatcher) Dispatch(e *event.Event)

Dispatch event

func (*Dispatcher) Error

func (d *Dispatcher) Error(index int) *eerr.Error

Error get single error by index

func (*Dispatcher) HasError

func (d *Dispatcher) HasError() bool

HasError check if got an error

func (*Dispatcher) Result

func (d *Dispatcher) Result(key string) string

Result get result with key

func (*Dispatcher) Results

func (d *Dispatcher) Results() map[string]string

Results get all results

type Filter

type Filter interface {
	// Execute do filtering
	Execute(req *restful.Request) *eerr.Error
}

Filter API request filter

type FilterExecutor

type FilterExecutor func(req *restful.Request) *eerr.Error

FilterExecutor filter handler function

type Initializer

type Initializer interface {
	// InitFilters set go-restful filters
	InitFilters()

	// InitServices set services
	InitServices()
}

Initializer of API server

type Route

type Route struct {
	Method  string
	Path    string
	Input   interface{}
	Handler RouteHandler
}

Route config element

type RouteHandler

type RouteHandler func(ctx *engine.Context, input interface{}) (interface{}, *eerr.Error)

RouteHandler route handler function

type Service

type Service interface {
	Name() string
	Routes() []*Route
}

Service API service

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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