Documentation ¶
Index ¶
- func Run(router *Router, transports ...Transport)
- type Client
- type ContextProvider
- type ContextWith
- type DefaultsSetter
- type EmptyOperator
- type Metadata
- type MetadataCarrier
- type MiddleOperators
- type Operator
- type OperatorFactory
- type OperatorInit
- type OperatorMeta
- type OperatorWithParams
- type OperatorWithoutOutput
- type Result
- type Route
- type Router
- type Routes
- type Transport
- type WithMiddleOperators
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{}) Run(RouterRoot, &FakeTransport{}) }
Output:
Types ¶
type ContextProvider ¶
type ContextProvider interface { Operator ContextKey() interface{} }
type ContextWith ¶
func ComposeContextWith ¶
func ComposeContextWith(contextWiths ...ContextWith) ContextWith
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 MiddleOperators ¶
type MiddleOperators []Operator
type OperatorFactory ¶
type OperatorFactory struct { Type reflect.Type ContextKey interface{} NoOutput bool Params url.Values IsLast bool Operator Operator }
func NewOperatorFactory ¶
func NewOperatorFactory(op Operator, last bool) *OperatorFactory
func (*OperatorFactory) New ¶
func (o *OperatorFactory) New() Operator
func (*OperatorFactory) String ¶
func (o *OperatorFactory) String() string
type OperatorInit ¶
type OperatorInit interface {
InitFrom(o Operator)
}
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 []*OperatorFactory)
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(&OperatorB2{})) fmt.Println(RouterRoot.Routes())
Output: courier.EmptyOperator |> courier.OperatorA |> courier.OperatorA1?allowedRoles=ADMIN&allowedRoles=OWNER courier.EmptyOperator |> courier.OperatorA |> courier.OperatorA2 courier.EmptyOperator |> courier.OperatorB |> courier.OperatorB1 |> courier.OperatorB2
type WithMiddleOperators ¶
type WithMiddleOperators interface {
MiddleOperators() MiddleOperators
}
Click to show internal directories.
Click to hide internal directories.