35 lines
570 B
Go
35 lines
570 B
Go
package api
|
|
|
|
import "github.com/go-chi/chi/v5"
|
|
|
|
type EndpointOption func(*Endpoint)
|
|
|
|
func AllowAnonymous() EndpointOption {
|
|
return func(endpoint *Endpoint) {
|
|
endpoint.AllowAnonymous = true
|
|
}
|
|
}
|
|
|
|
func UI() EndpointOption {
|
|
return func(endpoint *Endpoint) {
|
|
endpoint.UI = true
|
|
}
|
|
}
|
|
|
|
func EndpointOf(mount func(router chi.Router), opts ...EndpointOption) Endpoint {
|
|
ep := Endpoint{
|
|
Mount: mount,
|
|
}
|
|
|
|
for _, opt := range opts {
|
|
opt(&ep)
|
|
}
|
|
|
|
return ep
|
|
}
|
|
|
|
type Endpoint struct {
|
|
Mount func(router chi.Router)
|
|
UI bool
|
|
AllowAnonymous bool
|
|
}
|