server

package
v0.0.0-...-36345bc Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderContentType = "Content-Type"

	MimeApplicationXProtobuf = "application/x-protobuf"
	MimeApplicationJSON      = "application/json"
)
View Source
const (
	CtxKeyUser = "user"
)

Variables

This section is empty.

Functions

func Aborted

func Aborted(format string, a ...any) error

Aborted indicates the operation was aborted, typically due to a concurrency issue like sequencer check failures, transaction aborts, etc.

func AddUserver

func AddUserver(_ http.ResponseWriter, r *http.Request) (proto.Message, error)

func AlreadyExists

func AlreadyExists(format string, a ...any) error

AlreadyExists means an attempt to create an entity failed because one already exists.

func BadRequest

func BadRequest(format string, a ...any) error

BadRequest indicates client specified an invalid argument.

func ContextMiddleware

func ContextMiddleware(h http.Handler) http.Handler

func CorsMiddleware

func CorsMiddleware(h http.Handler) http.Handler

func DeleteUserver

func DeleteUserver(_ http.ResponseWriter, r *http.Request) (proto.Message, error)

func GetUserContext

func GetUserContext(r *http.Request) string

func HTTPStatusFromCode

func HTTPStatusFromCode(code codes.Code) int

func Internal

func Internal(format string, a ...any) error

Internal errors. Means some invariants expected by underlying system has been broken. If you see one of these errors, something is very broken.

func NewRouter

func NewRouter(mws []mux.MiddlewareFunc) *mux.Router

func NotFound

func NotFound(format string, a ...any) error

NotFound means some requested entity (e.g., file or directory) was not found.

func OutOfRange

func OutOfRange(format string, a ...any) error

OutOfRange means operation was attempted past the valid range. E.g., seeking or reading past end of file.

func PermissionDenied

func PermissionDenied(format string, a ...any) error

PermissionDenied indicates the caller does not have permission to execute the specified operation.

func RequestLogMiddleware

func RequestLogMiddleware(h http.Handler) http.Handler

func RetrieveUserver

func RetrieveUserver(_ http.ResponseWriter, r *http.Request) (proto.Message, error)

func RetrieveUservers

func RetrieveUservers(_ http.ResponseWriter, r *http.Request) (proto.Message, error)

func Stats

func UnmarshalReq

func UnmarshalReq(r *http.Request, req proto.Message) error

func Uptime

func WebSocketHandler

func WebSocketHandler(w http.ResponseWriter, r *http.Request)

Types

type Err

type Err struct {
	Cause   error
	Message string
	Code    int
}

func (Err) Error

func (e Err) Error() string

type JSONHandlerFunc

type JSONHandlerFunc func(http.ResponseWriter, *http.Request) (any, error) // NOTE any?

func (JSONHandlerFunc) ServeHTTP

func (fn JSONHandlerFunc) ServeHTTP(w http.ResponseWriter, r *http.Request)

type JSONRouterMap

type JSONRouterMap map[string]map[httpMethod]JSONHandlerFunc

type ProtoHandlerFunc

type ProtoHandlerFunc func(http.ResponseWriter, *http.Request) (proto.Message, error)

func (ProtoHandlerFunc) ServeHTTP

func (fn ProtoHandlerFunc) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ProtobufRouterMap

type ProtobufRouterMap map[string]map[httpMethod]ProtoHandlerFunc

type Server

type Server struct {
	ShutdownCtx context.Context
	BindAddress string
	Monitor     *ssm.Monitor
}

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

type Transport

type Transport struct {
	HTTPTransport http.Transport
}

func NewTransport

func NewTransport() (*Transport, error)

func (*Transport) ContainerProxy

func (t *Transport) ContainerProxy(w http.ResponseWriter, r *http.Request) (any, error)

Jump to

Keyboard shortcuts

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