Documentation
¶
Index ¶
- func OptionalBool(params map[string]interface{}, key string, fallback bool) bool
- func OptionalFloat64(params map[string]interface{}, key string, fallback float64) float64
- func OptionalInt(params map[string]interface{}, key string, fallback int) int
- func OptionalString(params map[string]interface{}, key, fallback string) string
- func RequireFloat64(params map[string]interface{}, key string) (float64, error)
- func RequireString(params map[string]interface{}, key string) (string, error)
- func StringSlice(params map[string]interface{}, key string) []string
- type ErrMissingParam
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OptionalBool ¶
OptionalBool extracts an optional boolean parameter with a fallback.
func OptionalFloat64 ¶ added in v0.7.0
OptionalFloat64 extracts an optional float64 parameter with a fallback.
func OptionalInt ¶
OptionalInt extracts an optional integer parameter with a fallback. JSON numbers arrive as float64, so this handles the conversion.
func OptionalString ¶
OptionalString extracts an optional string parameter with a fallback.
func RequireFloat64 ¶ added in v0.7.0
RequireFloat64 extracts a required float64 parameter. Returns ErrMissingParam when the key is absent.
func RequireString ¶
RequireString extracts a required string parameter. Returns ErrMissingParam when the key is absent or the value is empty.
func StringSlice ¶
StringSlice extracts a string slice from a parameter that arrives as []interface{}.
Types ¶
type ErrMissingParam ¶
type ErrMissingParam struct {
Name string
}
ErrMissingParam indicates a required parameter was empty or absent.
func (*ErrMissingParam) Error ¶
func (e *ErrMissingParam) Error() string
type Response ¶
type Response map[string]interface{}
Response is a convenience alias for tool handler return values.
func ListResponse ¶
ListResponse creates a Response with a named list and its count.
func StatusResponse ¶
StatusResponse creates a Response with a status field and optional extras.