Documentation ¶
Overview ¶
+gengo:runtimedoc=false
Index ¶
- func ContextWithClient(ctx context.Context, name string, client Client) context.Context
- func DoWith[Data any, Op interface{ ... }](ctx context.Context, c Client, req Op, metas ...Metadata) (*Data, error)
- func Run(router Router, transports ...Transport)
- type CanInit
- type CanInjectContext
- type Client
- type ContextInjector
- type ContextProvider
- type DefaultsSetter
- type EmptyOperator
- type Metadata
- type MetadataCarrier
- type MiddleOperators
- type NoContent
- type Operator
- type OperatorFactory
- type OperatorInit
- type OperatorNewer
- 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 ContextWithClient ¶
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 CanInjectContext ¶
type ContextInjector ¶
func ComposeContextWith ¶
func ComposeContextWith(injectContexts ...ContextInjector) ContextInjector
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 := []any{ 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 any 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 OperatorNewer ¶
type OperatorNewer interface {
New() Operator
}
type OperatorWithParams ¶
type OperatorWithoutOutput ¶
type OperatorWithoutOutput interface { Operator NoOutput() }
type 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.