contract

package
v0.9.14 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: Apache-2.0 Imports: 21 Imported by: 7

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, doc state.Documentation, filterDoc state.Documentation) 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 BodySelector

type BodySelector struct {
	StateValue string
}

BodySelector deprecated, use output parameter instead deprecated

type Contract

type Contract struct {
	Name       string `json:",omitempty" yaml:",omitempty"`
	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 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 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
}

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"`
	Style       Style             `json:",omitempty"`
	Title       string            `json:",omitempty"`
	//Filed defines optional main view data holder
	//deprecated
	Field            string `json:",omitempty"`
	Exclude          []string
	NormalizeExclude *bool
	DebugKind        view.MetaKind
	DataFormat       string `json:",omitempty"` //default data format
	ResponseBody     *BodySelector
	RevealMetric     *bool
	Type             state.Type
	ViewType         string
	Doc              state.Documentation
	FilterDoc        state.Documentation
	// 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) 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) 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

const (
	BasicStyle         Style = "Basic"
	ComprehensiveStyle Style = "Comprehensive"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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