router

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRouter

func NewRouter(opts ...Option) *router

Types

type Error

type Error struct {
	StatusCode int
	Message    string
}

type Handler

type Handler func(*codec.Message, string) *Error

type Node

type Node struct {
	Method             string              `json:"Method,omitempty"`
	Path               string              `json:"Path,omitempty"`
	ID                 string              `json:"ID"`
	Handler            Handler             `json:"-"`
	ValidationRules    govalidator.MapData `json:"ValidationRules,omitempty"`
	ValidationMessages govalidator.MapData `json:"ValidationMessages,omitempty"`
}

type Option

type Option func(*Options)

func Client

func Client(c *api.Client) Option

config consul client

func Name

func Name(n string) Option

type Options

type Options struct {
	Client *api.Client //consul client
	// contains filtered or unexported fields
}

type RejectHandler

type RejectHandler func(*codec.Message) error

type Router

type Router interface {
	Init(opts ...Option) error
	Routes() []*Node
	Add(*Node)
	Dispatch(*codec.Message) (Handler, error)
	HttpMatch(string, string) (*Node, error)
	Register() error
	Deregister() error
}

Jump to

Keyboard shortcuts

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