spec

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FS_ROUTING_BODY_PARAM   = "_body"
	FS_ROUTING_METHOD_PARAM = "_method"
	FS_ROUTING_INDEX_MODULE = "index" + inoxconsts.INOXLANG_FILE_EXTENSION
)
View Source
const (
	MAX_PATH_PARAM_COUNT = 5
)

Variables

View Source
var (
	ErrEndpointNotFound    = errors.New("endpoint not found")
	ErrAPINotFinalized     = errors.New("API value is not finalized")
	ErrAPIAlreadyFinalized = errors.New("API value is already finalized")
	ErrAPIBeingFinalized   = errors.New("API value is being finalized")
)
View Source
var (
	ErrFailedCreateApiFromOApenpiSpec = errors.New("failed to create API from Open API/Swagger specification")
	ErrUnsupportedMediaTypeinSpec     = errors.New("unsupported media type (in spec)")
	ErrOpenAPIV2SpecNotSupported      = errors.New("specification in the Open Api 2.0 & Swagger formats are not supported, see https://converter.swagger.io/#/Converter/convertByContent to convert to OpenAPI 3+ format")
)
View Source
var (
	METHODS_WITH_NO_BODY = []string{"GET", "HEAD", "OPTIONS"}
	METHODS              = []string{"GET", "HEAD", "OPTIONS", "PUT", "POST", "PATCH", "DELETE"}
	FS_ROUTING_METHODS   = []string{"GET", "OPTIONS", "POST", "PATCH", "PUT", "DELETE"}

	METHOD_PATTERN = core.NewUnionPattern(utils.MapSlice(METHODS, func(s string) core.Pattern {
		return core.NewExactValuePattern(core.Identifier(s))
	}), nil)
)
View Source
var (
	ErrUnexpectedBodyParamsInGETHandler      = errors.New("unexpected request body parmameters in GET handler")
	ErrUnexpectedBodyParamsInOPTIONSHandler  = errors.New("unexpected request body parmameters in OPTIONS handler")
	ErrUnexpectedBodyParamsInCatchAllHandler = errors.New("unexpected request body parmameters in catch-all handler")
)

Functions

This section is empty.

Types

type API

type API struct {
	// contains filtered or unexported fields
}

API is a high level type that contains several endpoints, it is immutable.

func GetFSRoutingServerAPI

func GetFSRoutingServerAPI(ctx *core.Context, dir string, config ServerApiResolutionConfig) (*API, error)

func NewAPI

func NewAPI(endpoints map[string]*ApiEndpoint) (*API, error)

func NewEmptyAPI

func NewEmptyAPI() *API

func (*API) ForEachHandlerModule

func (api *API) ForEachHandlerModule(visit HandlerModuleVisitFn) error

ForEachHandlerModule visits all handler modules in the API. If $endpoint.CatchAll() is true the handler handles all operations and $operation is not set.

func (*API) GetEndpoint

func (api *API) GetEndpoint(path string) (*ApiEndpoint, error)

type ApiEndpoint

type ApiEndpoint struct {
	// contains filtered or unexported fields
}

APIEndpoint represents an endpoint and its supported operations (GET, POST, ...). APIEndpoint is immutable.

func (ApiEndpoint) CatchAll

func (e ApiEndpoint) CatchAll() bool

func (ApiEndpoint) CatchAllHandler

func (e ApiEndpoint) CatchAllHandler() (*core.Module, bool)

func (ApiEndpoint) GetPathParams

func (e ApiEndpoint) GetPathParams(path string) (params PathParams, count int, err error)

func (ApiEndpoint) Operations

func (e ApiEndpoint) Operations() []ApiOperation

func (ApiEndpoint) PathWithParams

func (e ApiEndpoint) PathWithParams() string

type ApiOperation

type ApiOperation struct {
	// contains filtered or unexported fields
}

func (ApiOperation) HandlerModule

func (op ApiOperation) HandlerModule() (*core.Module, bool)

func (ApiOperation) HttpMethod

func (op ApiOperation) HttpMethod() string

func (ApiOperation) JSONRequestBodyPattern

func (op ApiOperation) JSONRequestBodyPattern() (core.Pattern, bool)

type EndpointPathSegment

type EndpointPathSegment struct {
	Constant      string
	ParameterName string
}

type EndpointTreeNode

type EndpointTreeNode struct {
	// contains filtered or unexported fields
}

type HandlerModuleVisitFn

type HandlerModuleVisitFn func(
	mod *core.Module,
	endpoint *ApiEndpoint,

	operation ApiOperation,
) error

type PathParam

type PathParam struct {
	Name  string
	Value string
}

func (PathParam) IsSet

func (param PathParam) IsSet() bool

type PathParams

type PathParams [5]PathParam

type ServerApiResolutionConfig

type ServerApiResolutionConfig struct {
	IgnoreModulesWithErrors bool
}

Jump to

Keyboard shortcuts

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