api

package
v0.0.0-...-7d38a10 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	Config *Config
	Server *http.Server
}

func New

func New(config *Config) *API

func (*API) Start

func (a *API) Start() (shutdown func())

func (*API) ValidateUserToken

func (a *API) ValidateUserToken(r *http.Request) (int64, bool)

type Config

type Config struct {
	Port                  string
	StaticDir             string
	Validate              validate
	RetrieveAccessDetails retrieveAccessDetails
	Endpoints             []*Endpoint
}

type Endpoint

type Endpoint struct {
	Path   string
	Method string
	Auth   bool
	Handle func(r *Request) *Response
}

type Request

type Request struct {
	Req    *http.Request
	UserID int64
	Vars   map[string]string
}

func (*Request) Decode

func (r *Request) Decode(out interface{}) error

type Response

type Response struct {
	StatusCode int
	Body       interface{}
	Header     http.Header
}

func NewResponse

func NewResponse(status int, body interface{}) *Response

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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