apiserver

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2023 License: MIT Imports: 15 Imported by: 0

README

-apiServer-go

Standardised API Server package

-apiServer-go is part of the kiss-my-package set used by apps like FaceMasq, PaperBag, Celestial, Executrix, and more

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadJSONBody

func ReadJSONBody(in bunrouter.Request, target interface{}) error

func WriteJSONResponse

func WriteJSONResponse(payload interface{}, out http.ResponseWriter, _ bunrouter.Request)

func WriteTextResponse

func WriteTextResponse(payload string, out http.ResponseWriter, _ bunrouter.Request)

Types

type CORSHandler

type CORSHandler struct {
	Next http.Handler
}

func (CORSHandler) ServeHTTP

func (handler CORSHandler) ServeHTTP(out http.ResponseWriter, in *http.Request)

type Server

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

func FromContext

func FromContext(ctx context.Context) *Server

func GetServer

func GetServer() *Server

func New

func New(version, port int, db *database.DBConn, translator *translate.Translator, conf *config.Configuration, hosts ...string) *Server

func ToContext

func ToContext(ctx context.Context, version, port int, db *database.DBConn, translator *translate.Translator, conf *config.Configuration, host ...string) (*Server, context.Context)

func (*Server) AddMiddleware

func (server *Server) AddMiddleware(ctx context.Context, middlewares ...func(next bunrouter.HandlerFunc) bunrouter.HandlerFunc)

func (*Server) AddRoutes

func (server *Server) AddRoutes(ctx context.Context, static bool, routes ...func(ctx context.Context, group *bunrouter.Group, db *database.DBConn, translator *translate.Translator, conf *config.Configuration))

func (*Server) Addresses

func (server *Server) Addresses() []string

func (*Server) Run

func (server *Server) Run(ctx context.Context) error

func (*Server) ToContext

func (server *Server) ToContext(ctx context.Context) context.Context

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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