Documentation ¶
Index ¶
- func Run(router *Router, transports ...Transport)
- type Client
- type ContextProvider
- type DefaultsSetter
- type EmptyOperator
- type Metadata
- type MetadataCarrier
- type Operator
- type OperatorMeta
- type OperatorWithParams
- type OperatorWithoutOutput
- type Result
- type Route
- type Router
- type Routes
- type Transport
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Run ¶
Example ¶
package main import ( "fmt" ) type FakeTransport struct { } func (FakeTransport) UnmarshalOperator(op Operator) error { return nil } func (FakeTransport) Serve(router *Router) error { return fmt.Errorf("some thing wrong") } func main() { var RouterRoot = NewRouter(&EmptyOperator{}) err := TryCatch(func() { Run(RouterRoot, &FakeTransport{}) }) fmt.Println(err) }
Output: some thing wrong
Types ¶
type ContextProvider ¶
type DefaultsSetter ¶
type DefaultsSetter interface {
SetDefaults()
}
type EmptyOperator ¶
type EmptyOperator struct {
OperatorWithoutOutput
}
type Metadata ¶
Example ¶
metaA := Metadata{} metaA.Add("A", "valueA1") metaA.Add("A", "valueA2") metaB := Metadata{} metaB.Set("B", "valueB1") metaAll := FromMetas(metaA, metaB) results := []interface{}{ metaAll.String(), metaAll.Has("A"), metaAll.Get("A"), } metaAll.Del("B") results = append(results, metaAll.Get("B"), metaAll.String(), ) for _, r := range results { fmt.Printf("%v\n", r) }
Output: A=valueA1&A=valueA2&B=valueB1 true valueA1 A=valueA1&A=valueA2
type MetadataCarrier ¶
type MetadataCarrier interface {
Meta() Metadata
}
type OperatorMeta ¶
type OperatorMeta struct { Type reflect.Type ContextKey string Params url.Values IsLast bool Operator }
func NewOperatorFactory ¶
func NewOperatorFactory(op Operator, last bool) *OperatorMeta
func (*OperatorMeta) New ¶
func (o *OperatorMeta) New() Operator
func (*OperatorMeta) String ¶
func (o *OperatorMeta) String() string
type OperatorWithParams ¶
type OperatorWithoutOutput ¶
type OperatorWithoutOutput interface { Operator NoOutput() }
type Route ¶
type Route struct { Operators []Operator // contains filtered or unexported fields }
func (*Route) OperatorFactories ¶
func (route *Route) OperatorFactories() (operatorFactories []*OperatorMeta)
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router
func NewRouter ¶
Example ¶
var RouterRoot = NewRouter(&EmptyOperator{}) var RouterA = NewRouter(&OperatorA{}) var RouterB = NewRouter(&OperatorB{}) RouterRoot.Register(RouterA) RouterRoot.Register(RouterB) RouterA.Register(NewRouter(&OperatorA1{})) RouterA.Register(NewRouter(&OperatorA2{})) RouterB.Register(NewRouter(&OperatorB1{}, OperatorB2{})) fmt.Println(RouterRoot.Routes())
Output: courier.OperatorA |> courier.OperatorA1?allowedRoles=ADMIN&allowedRoles=OWNER courier.OperatorA |> courier.OperatorA2 courier.OperatorB |> courier.OperatorB1 |> courier.OperatorB2
Click to show internal directories.
Click to hide internal directories.