toolparam

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OptionalBool

func OptionalBool(params map[string]interface{}, key string, fallback bool) bool

OptionalBool extracts an optional boolean parameter with a fallback.

func OptionalFloat64 added in v0.7.0

func OptionalFloat64(params map[string]interface{}, key string, fallback float64) float64

OptionalFloat64 extracts an optional float64 parameter with a fallback.

func OptionalInt

func OptionalInt(params map[string]interface{}, key string, fallback int) int

OptionalInt extracts an optional integer parameter with a fallback. JSON numbers arrive as float64, so this handles the conversion.

func OptionalString

func OptionalString(params map[string]interface{}, key, fallback string) string

OptionalString extracts an optional string parameter with a fallback.

func RequireFloat64 added in v0.7.0

func RequireFloat64(params map[string]interface{}, key string) (float64, error)

RequireFloat64 extracts a required float64 parameter. Returns ErrMissingParam when the key is absent.

func RequireString

func RequireString(params map[string]interface{}, key string) (string, error)

RequireString extracts a required string parameter. Returns ErrMissingParam when the key is absent or the value is empty.

func StringSlice

func StringSlice(params map[string]interface{}, key string) []string

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

func ListResponse(key string, items interface{}, count int) Response

ListResponse creates a Response with a named list and its count.

func StatusResponse

func StatusResponse(status string, extras ...func(Response)) Response

StatusResponse creates a Response with a status field and optional extras.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL