rest

package
v0.0.0-...-4a142f4 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2018 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FormatText   = ParameterValueFormat(0)
	FormatJSON   = ParameterValueFormat(1)
	FormatBinary = ParameterValueFormat(2)
	FormatXML    = ParameterValueFormat(3)
)

Formats

View Source
const (
	TemplateParamBody = "body"
)

Variables

This section is empty.

Functions

func CreateEndpointHandler

func CreateEndpointHandler(endpoint Endpoint) http.HandlerFunc

creates HTTP handler for the specified endpoint

func ExtractQueryParameters

func ExtractQueryParameters(url *url.URL, separator string) map[string]string

Types

type ArrayParameter

type ArrayParameter interface {
	Parameter
	ElementType() Parameter
}

type BoolParameter

type BoolParameter interface {
	Parameter
	DefaultValue() bool
}

Represents parameter of type Boolean

type Endpoint

type Endpoint interface {
	ModelElement
	PathParameters() ParameterList //path parameters
	GetMethodDescriptor(method string) HttpMethodDescriptor
}

Describes single endpoint

type FastCGI

type FastCGI struct {
	Model Model
}

func (*FastCGI) Close

func (self *FastCGI) Close() error

func (*FastCGI) Run

func (self *FastCGI) Run(async bool) error

type FileParameter

type FileParameter interface {
	Parameter
	//Indicates that file should be saved into temporary file. Otherwise, it will be recorded into memory
	Persistent() bool
}

Represents file content as a parameter value of this parameter can be represented as BASE64 string in case of plain/text format value of this parameter can be represented as quoted BASE64 string in case of application/json format value of this parameter can be represented as raw set of bytes in case of application/octet-stream format

type HttpMethodDescriptor

type HttpMethodDescriptor interface {
	ModelElement
	Executor() cmdexec.CommandExecutor
	QueryParameters() ParameterList
	RequestHeaders() ParameterList
	Request() ParameterList               //definition of body bounded to MIME types
	Response() map[int]ResponseDescriptor //mapping between exit code of process and response
}

Describes HTTP method

type IntegerParameter

type IntegerParameter interface {
	Parameter
	DefaultValue() int64 //default value of parameter
}

type Model

type Model interface {
	Endpoints() map[string]Endpoint //set of endpoints declared in the model
	Name() string                   //name of model
}

REST model describes command execution

type ModelElement

type ModelElement interface {
	//Indicates that custom option is defined for model element
	HasOption(directive string) bool
}

Represents model element

type NumberParameter

type NumberParameter interface {
	Parameter
	DefaultValue() float64
}

type ObjectParameter

type ObjectParameter interface {
	Parameter
	Fields() ParameterList
}

type Parameter

type Parameter interface {
	ModelElement
	Required() bool                  //parameter is required to be presented
	HasDefaultValue() bool           //parameter has default value
	Validate(value interface{}) bool //validate value of parameter
	ReadValue(value io.Reader, format ParameterValueFormat) (interface{}, error)
}

Represents parameter in model this interface can be used to represent variant parameter type

type ParameterList

type ParameterList map[string]Parameter

Represents list of parameters

type ParameterValueFormat

type ParameterValueFormat int8

func GetFormatByMIME

func GetFormatByMIME(mediaType string) ParameterValueFormat

type ResponseDescriptor

type ResponseDescriptor struct {
	Body       Parameter //response parameter description
	StatusCode int       //HTTP status code
	MimeType   string    //MIME type
}

Describes response associated with exit code

type StandaloneServer

type StandaloneServer struct {
	http.Server
	CertFile, KeyFile string
	Model             Model
}

func (*StandaloneServer) Close

func (self *StandaloneServer) Close() error

func (*StandaloneServer) Run

func (self *StandaloneServer) Run(async bool) error

type StringParameter

type StringParameter interface {
	Parameter
	DefaultValue() string
}

Represents parameter of type String

type UnsupportedParameterValueFormat

type UnsupportedParameterValueFormat struct {
}

func (UnsupportedParameterValueFormat) Error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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