Documentation ¶
Overview ¶
Package endpoint contains offers for configuring and constructing github.com/go-kit/kit/endpoint.Endpoint.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config is a group of options for a endpoint Set.
func (Config) Middleware ¶
func (c Config) Middleware() endpoint.Middleware
Middleware returns a composed middlewares. Requests will traverse them in the order they're declared.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
A Option sets options to config.
func WithMiddlewares ¶
func WithMiddlewares( middlewares ...endpoint.Middleware, ) Option
WithMiddlewares returns an Option that appends middlewares to the configured endpoint.
Example ¶
package main import ( "context" "fmt" kitendpoint "github.com/go-kit/kit/endpoint" "github.com/gorhythm/concerto/endpoint" ) func main() { cfg := endpoint.NewConfig( endpoint.WithMiddlewares( annotate("first"), annotate("second"), annotate("third"), ), ) e := cfg.Middleware()(myEndpoint) if _, err := e(context.Background(), struct{}{}); err != nil { panic(err) } } func annotate(s string) kitendpoint.Middleware { return func(next kitendpoint.Endpoint) kitendpoint.Endpoint { return func(ctx context.Context, req any) (any, error) { fmt.Println(s, "pre") defer fmt.Println(s, "post") return next(ctx, req) } } } func myEndpoint(context.Context, any) (any, error) { fmt.Println("my endpoint!") return struct{}{}, nil }
Output: first pre second pre third pre my endpoint! third post second post first post
Directories ¶
Path | Synopsis |
---|---|
middleware
|
|
callmeta
Package callmeta provides middleware for setting CallMeta (service name, method name, transport) to the context of the request.
|
Package callmeta provides middleware for setting CallMeta (service name, method name, transport) to the context of the request. |
Click to show internal directories.
Click to hide internal directories.