endpoints

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMethodNotSupported     = errors.New("method not supported")
	ErrXForwardedMethodNotSet = errors.New("header X-Forwarded-Method isn't set")
	ErrNoCookie               = errors.New("http: named cookie not present")
	ErrNoHeader               = errors.New("missing parameters header")
	ErrNoQueryParam           = errors.New("missing query param")
	ErrInvalidLocation        = errors.New("invalid `in` value for parameters")

	ErrEndpointNotFound = errors.New("no endpoint matches request")

	ErrInvalidTemplating                = errors.New("not a valid template string")
	ErrBracketsMustNotBeNextToEachOther = errors.New("brackets must not be next to each other")
	ErrBracketsCannotBeNested           = errors.New("brackets cannot be nested")
	ErrBracketNotClosed                 = errors.New("bracket wasn't closed")
	ErrBracketNotOpened                 = errors.New("bracket not opened before closed")
	ErrColonNotAllowed                  = errors.New("`:` not allowed in templating")
	ErrSlashNotAllowed                  = errors.New("`/` not allowed in templating")
)

Functions

func ErrParameterNotDefined

func ErrParameterNotDefined(param string) error

Types

type ComponentsConfig

type ComponentsConfig struct {
	SecuritySchemas map[string]SecuritySchemaConfig
}

func (ComponentsConfig) Validate

func (c ComponentsConfig) Validate() error

type Endpoint

type Endpoint struct {
	Parameters map[string]string
	Security   []SecurityConfig
	Audience   []string
}

type EndpointsConfig

type EndpointsConfig struct {
	Components ComponentsConfig
	Paths      PathsConfig
}

func LoadEndpointsYAML

func LoadEndpointsYAML(fileName string, config *EndpointsConfig) (*EndpointsConfig, error)

func LoadMultipleEndpoints

func LoadMultipleEndpoints(files []string) (*EndpointsConfig, error)

func (EndpointsConfig) Validate

func (c EndpointsConfig) Validate() error

type Method

type Method struct {
	Parameters []ParameterConfig
	Security   []SecurityConfig
	Audience   []string
}

type MethodConfig

type MethodConfig struct {
	Parameters []ParameterConfig
	Security   []SecurityConfig
	Audience   []string `yaml:"x-audience"`
}

func (MethodConfig) Validate

func (c MethodConfig) Validate() error

type ParameterConfig

type ParameterConfig struct {
	In   string
	Name string
}

func (ParameterConfig) Validate

func (c ParameterConfig) Validate() error

type Path

type Path struct {
	URL      string
	Segments []string

	Get    *Method
	Post   *Method
	Put    *Method
	Delete *Method
	Patch  *Method
}

type PathConfig

type PathConfig struct {
	Get    *MethodConfig
	Post   *MethodConfig
	Put    *MethodConfig
	Delete *MethodConfig
	Patch  *MethodConfig
}

func (PathConfig) Validate

func (c PathConfig) Validate() error

type PathsConfig

type PathsConfig map[string]PathConfig

func (PathsConfig) Validate

func (c PathsConfig) Validate() error

type SecurityConfig

type SecurityConfig struct {
	Identity []string
	Keyring  []string
}

func (SecurityConfig) Validate

func (c SecurityConfig) Validate() error

type SecuritySchemaConfig

type SecuritySchemaConfig struct {
	Type string

	// Used in cookies, api key (say in a header)
	In string

	// Where to pull it from
	Name string

	// Using in Bearer Auth
	Scheme string
}

func (SecuritySchemaConfig) Validate

func (c SecuritySchemaConfig) Validate() error

type Service

type Service interface {
	LoadConfig(config EndpointsConfig) error
	MatchRequest(req common.Request) (*Endpoint, error)
}

func NewService

func NewService(log logging.Logger, config EndpointsConfig) (Service, error)

Jump to

Keyboard shortcuts

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