-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathroute_option.go
More file actions
25 lines (21 loc) · 797 Bytes
/
route_option.go
File metadata and controls
25 lines (21 loc) · 797 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package navaros
// RouteOption is an interface for options that can be passed alongside
// handlers and transformers when binding routes. Route options are
// extracted before handler validation and do not participate in the
// handler chain.
type RouteOption interface {
isRouteOption()
}
// MetadataOption is a RouteOption that carries arbitrary metadata to be
// attached to the route descriptor.
type MetadataOption struct {
value any
}
func (MetadataOption) isRouteOption() {}
// WithMetadata creates a RouteOption that attaches arbitrary metadata to
// the route descriptor. This metadata can be used by gateways and
// middleware to implement features like rate limiting, auth requirements,
// etc.
func WithMetadata(value any) MetadataOption {
return MetadataOption{value: value}
}