apiserver

package
v0.27.2 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIServer

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

APIServer APIServer

func NewAPIServer

func NewAPIServer(props *APIServerProps) *APIServer

NewAPIServer NewAPIServer

func (*APIServer) Start

func (s *APIServer) Start(routeMapping map[string]RouteHandler)

type APIServerProps

type APIServerProps struct {
	Port string
}

type Context

type Context struct {
	Res    http.ResponseWriter
	Req    *http.Request
	Safe   func()
	Params map[string]string
}

func (*Context) Decode

func (c *Context) Decode(ptr interface{})

func (*Context) Error

func (c *Context) Error(message string)

func (*Context) GetParam

func (c *Context) GetParam(name string) *Param

func (*Context) GetQueryInt

func (c *Context) GetQueryInt(name string, defaultValue int) int

func (*Context) GetQueryString

func (c *Context) GetQueryString(name string, defaultValue string) string

func (*Context) GetRequiredParam

func (c *Context) GetRequiredParam(name string) *Param

func (*Context) SendJSON

func (c *Context) SendJSON(data interface{})

func (*Context) SendOK

func (c *Context) SendOK()

func (*Context) Unauthorized

func (c *Context) Unauthorized()

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error"`
}

type Param

type Param struct {
	Raw string
}

func (*Param) AsInt

func (p *Param) AsInt() int

func (*Param) AsInt64

func (p *Param) AsInt64() int64

func (*Param) AsString

func (p *Param) AsString() string

type RouteHandler

type RouteHandler func(context *Context)

Jump to

Keyboard shortcuts

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