contract

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: Apache-2.0 Imports: 22 Imported by: 28

Documentation

Index

Constants

View Source
const (
	FormatQuery = "_format"
)

Variables

This section is empty.

Functions

func DataOutputParameter

func DataOutputParameter(name string) *state.Parameter

func DefaultDataOutputParameter

func DefaultDataOutputParameter() *state.Parameter

func DefaultStatusOutputParameter

func DefaultStatusOutputParameter() *state.Parameter

func EnsureParameterTypes

func EnsureParameterTypes(parameters []*state.Parameter, aView *view.View) error

EnsureParameterTypes update output kind parameter type

func StatusSuccess

func StatusSuccess(state *expand.State) response.Status

TODO move it to some other package

func UpdateOutputParameterType

func UpdateOutputParameterType(parameter *state.Parameter)

func UpdateParameterAsyncType

func UpdateParameterAsyncType(parameter *state.Parameter)

func UpdateParameterMetaType

func UpdateParameterMetaType(parameter *state.Parameter)

Types

type Contract

type Contract struct {
	Input      Input
	Output     Output
	ModulePath string
	Service    service.Type `json:",omitempty"`
}

func (*Contract) BodyType

func (c *Contract) BodyType() reflect.Type

func (*Contract) Init

func (c *Contract) Init(ctx context.Context, path *Path, aView *view.View, resource *view.Resource) (err error)

func (*Contract) OutputType

func (c *Contract) OutputType() reflect.Type

func (*Contract) Types

func (c *Contract) Types() []*state.Type

Types returns all types

type Dispatcher

type Dispatcher interface {
	//Dispatch dispatches request
	Dispatch(ctx context.Context, path *Path, options ...Option) (interface{}, error)
}

Dispatcher represents a dispatcher

type Input

type Input struct {
	Body                       state.Type
	Type                       state.Type
	CustomValidation           bool `json:",omitempty"`
	IgnoreEmptyQueryParameters bool `json:",omitempty"`
}

func (*Input) Init

func (i *Input) Init(ctx context.Context, aView *view.View) error

type Meta added in v0.16.2

type Meta struct {
	Name           string `json:",omitempty" yaml:"Name"`        // name of the MCP
	Description    string `json:",omitempty" yaml:"Description"` // optional description for documentation purposes
	DescriptionURI string `json:",omitempty" yaml:"DescriptionURI"`
}

MCP Model Configuration Protocol path integration

func (*Meta) Build added in v0.17.0

func (m *Meta) Build(name string, from string, aPath *Path) *Meta

type ModelContextProtocol added in v0.16.2

type ModelContextProtocol struct {
	MCPTool             bool `json:",omitempty" yaml:"MCPTool"`
	MCPResource         bool `json:",omitempty" yaml:"MCPResource"`
	MCPTemplateResource bool `json:",omitempty" yaml:"MCPTemplateResource"`
}

func (*ModelContextProtocol) HasMCPIntegration added in v0.16.2

func (m *ModelContextProtocol) HasMCPIntegration() bool

type Option added in v0.9.2

type Option func(o *Options)

Option represents a dispatcher option

func WithConstants added in v0.9.2

func WithConstants(constants map[string]interface{}) Option

WithConstants adds constants

func WithForm added in v0.9.7

func WithForm(form *hstate.Form) Option

WithForm adds form

func WithHeader added in v0.9.12

func WithHeader(header http.Header) Option

WithHeader adds header

func WithLogger added in v0.20.9

func WithLogger(loger logger.Logger) Option

WithLogger adds path parameters

func WithPath added in v0.9.12

func WithPath(pathParameters map[string]string) Option

WithPath adds path parameters

func WithQuery added in v0.9.12

func WithQuery(query url.Values) Option

WithQuery adds query parameters

func WithRequest added in v0.9.7

func WithRequest(request *http.Request) Option

WithRequest adds request

type Options added in v0.9.2

type Options struct {
	Constants      map[string]interface{}
	PathParameters map[string]string
	Query          url.Values
	Header         http.Header
	Form           *hstate.Form
	Request        *http.Request
	Logger         logger.Logger
}

Options represents dispatcher options

func NewOptions added in v0.9.2

func NewOptions(opts ...Option) *Options

NewOptions creates a new options

type Output

type Output struct {
	Cardinality      state.Cardinality `json:",omitempty"`
	CaseFormat       text.CaseFormat   `json:",omitempty"`
	OmitEmpty        bool              `json:",omitempty"`
	Title            string            `json:",omitempty"`
	Exclude          []string
	NormalizeExclude *bool
	DebugKind        view.MetaKind
	DataFormat       string `json:",omitempty"` //default data format
	RevealMetric     *bool
	Type             state.Type
	ViewType         string
	// contains filtered or unexported fields
}

func (*Output) ContentType

func (o *Output) ContentType(format string) string

func (*Output) Excluded

func (o *Output) Excluded() map[string]bool

func (*Output) Field

func (r *Output) Field() string

func (*Output) Format

func (o *Output) Format(query url.Values) string

func (*Output) GetTitle

func (o *Output) GetTitle() string

func (*Output) Init

func (o *Output) Init(ctx context.Context, aView *view.View, inputType *state.Type, isReader bool) (err error)

func (*Output) IsExcluded added in v0.10.0

func (o *Output) IsExcluded(path string) bool

func (*Output) IsRevealMetric

func (o *Output) IsRevealMetric() bool

func (*Output) ShouldNormalizeExclude

func (o *Output) ShouldNormalizeExclude() bool

type Path

type Path struct {
	URI    string `json:",omitempty" yaml:"URI"`
	Method string `json:",omitempty" yaml:"Method"`
	// contains filtered or unexported fields
}

func NewPath

func NewPath(method, uri string) *Path

func (*Path) Equals

func (r *Path) Equals(candidate *Path) bool

func (*Path) HttpMethod

func (r *Path) HttpMethod() string

func (*Path) Key

func (r *Path) Key() string

type Style

type Style string

Style defines style TODO deprecate with function on input parameters to determine style

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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