mirror of
https://github.com/hanzoai/beego.git
synced 2026-11-17 13:19:25 +00:00
Faithful fork of upstream beego v1.12.12 with two changes only: - module path github.com/beego/beego -> github.com/hanzoai/beego (all internal imports repointed) - orm sqlite3 test driver mattn/go-sqlite3 -> hanzoai/csqlite (drop-in); drops the bogus 'mattn/go-sqlite3 v2.0.3+incompatible' pin that poisoned every consumer's module graph via beego v1's go.mod. go build ./... green; go list -deps mattn = 0; grep mattn go.mod = 0. Behavior identical to upstream v1.12.12 (no logic changes). Lets ai repoint its beego-v1 web layer by import path only, preserving exact runtime behavior.
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)
|
|
}
|
|
}
|
|
}
|