mirror of
https://github.com/hanzoai/beego.git
synced 2026-11-17 13:19:25 +00:00
Patches against upstream beego/[email protected]: server/web/admin_controller.go — promhttp.Handler → luxfi/metric HTTP handler server/web/filter/prometheus/ — luxfi/metric backend, drops MustRegister client/httplib/filter/prometheus/ — luxfi/metric backend client/orm/filter/prometheus/ — luxfi/metric backend core/config/etcd/config.go — drop grpc-ecosystem/go-grpc-prometheus interceptors (etcd dialing has no observability through this path) Default closure: 0 grpc, 0 protobuf, 0 prometheus/client_golang. Consumers in hanzoai/iam see the fork through workspace mode.
38 lines
964 B
Go
38 lines
964 B
Go
package param
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
// MethodParamOption defines a func which apply options on a MethodParam
|
|
type MethodParamOption func(*MethodParam)
|
|
|
|
// IsRequired indicates that this param is required and can not be omitted from the http request
|
|
var IsRequired MethodParamOption = func(p *MethodParam) {
|
|
p.required = true
|
|
}
|
|
|
|
// InHeader indicates that this param is passed via an http header
|
|
var InHeader MethodParamOption = func(p *MethodParam) {
|
|
p.in = header
|
|
}
|
|
|
|
// InPath indicates that this param is part of the URL path
|
|
var InPath MethodParamOption = func(p *MethodParam) {
|
|
p.in = path
|
|
}
|
|
|
|
// InBody indicates that this param is passed as an http request body
|
|
var InBody MethodParamOption = func(p *MethodParam) {
|
|
p.in = body
|
|
}
|
|
|
|
// Default provides a default value for the http param
|
|
func Default(defaultValue interface{}) MethodParamOption {
|
|
return func(p *MethodParam) {
|
|
if defaultValue != nil {
|
|
p.defaultValue = fmt.Sprint(defaultValue)
|
|
}
|
|
}
|
|
}
|