rest

package
v0.0.0-...-9869d36 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: MIT Imports: 14 Imported by: 0

README

REST Server

REST API Server that exposes Store functionality

Usage

srv := rest.Server(generated.Schema(), store_to_expose,
    rest.TypeMethods(generated.WorldKind(),
        rest.ActionGet, rest.ActionCreate,
        rest.ActionDelete, rest.ActionUpdate),
    rest.TypeMethods("AnotherWorld", rest.ActionGet))
)

// use cancel function to stop server
cancel = srv.Listen(port) // does not block

Documentation

Index

Constants

View Source
const (
	PropFilterArg  = "pf"
	KeyFilterArg   = "kf"
	IncrementalArg = "inc"
	PageSizeArg    = "pageSize"
	PageOffsetArg  = "pageOffset"
	OrderByArg     = "orderBy"
)

Variables

This section is empty.

Functions

func Server

func Server(schema store.SchemaHolder, stor store.Store, exposed ..._TypeMethods) store.Endpoint

func TypeMethods

func TypeMethods(kind string, actions ...Action) _TypeMethods

Types

type Action

type Action string
const (
	ActionCreate Action = http.MethodPost
	ActionUpdate Action = http.MethodPut
	ActionDelete Action = http.MethodDelete
	ActionGet    Action = http.MethodGet
)

Jump to

Keyboard shortcuts

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