web

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateBytesUUID

func GenerateBytesUUID() []byte

GenerateBytesUUID returns a UUID based on RFC 4122 returning the generated bytes

func GenerateUUID

func GenerateUUID() string

GenerateUUID returns a UUID based on RFC 4122

func InstallViewHandler

func InstallViewHandler(l logger, sp view.ServiceProvider, h *HttpHandler)

Types

type Config

type Config struct {
	MaxReqSize uint16
}

type Dispatcher

type Dispatcher struct {
	Logger  logger
	Handler *HttpHandler
	// contains filtered or unexported fields
}

func (*Dispatcher) HandleRequest

func (rd *Dispatcher) HandleRequest(context *ReqContext) (response interface{}, statusCode int)

func (*Dispatcher) ParsePayload

func (rd *Dispatcher) ParsePayload(bytes []byte) (interface{}, error)

func (*Dispatcher) WireStreamViewCaller added in v0.3.0

func (rd *Dispatcher) WireStreamViewCaller(vc ViewCaller)

func (*Dispatcher) WireViewCaller

func (rd *Dispatcher) WireViewCaller(vc ViewCaller)

type DummyServer added in v0.2.0

type DummyServer struct{}

func NewDummyServer added in v0.2.0

func NewDummyServer() *DummyServer

func (*DummyServer) RegisterHandler added in v0.2.0

func (d *DummyServer) RegisterHandler(s string, handler http.Handler, secure bool)

func (*DummyServer) Start added in v0.2.0

func (d *DummyServer) Start() error

func (*DummyServer) Stop added in v0.2.0

func (d *DummyServer) Stop() error

type HttpHandler

type HttpHandler struct {
	Logger logger
	// contains filtered or unexported fields
}

func NewHttpHandler

func NewHttpHandler(l logger) *HttpHandler

func (*HttpHandler) RegisterURI

func (h *HttpHandler) RegisterURI(uri string, method string, rh RequestHandler)

func (*HttpHandler) ServeHTTP

func (h *HttpHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

type Input added in v0.3.0

type Input struct {
	Raw []byte
}

type Logger

type Logger interface {
	Debugf(template string, args ...interface{})
	Warnf(template string, args ...interface{})
	Infof(template string, args ...interface{})
	Errorf(template string, args ...interface{})
	Warn(args ...interface{})
}

type Options

type Options struct {
	Logger        Logger
	ListenAddress string
	TLS           TLS
}

type Output added in v0.3.0

type Output struct {
	Raw []byte
}

type ReqContext

type ReqContext struct {
	ResponseWriter http.ResponseWriter
	Req            *http.Request
	Vars           map[string]string
	Query          interface{}
}

type RequestHandler

type RequestHandler interface {
	// HandleRequest dispatches the request in the backend by parsing the given request context
	// and returning a status code and a response back to the client.
	HandleRequest(*ReqContext) (response interface{}, statusCode int)

	// ParsePayload parses the payload to handler specific form or returns an error
	ParsePayload([]byte) (interface{}, error)
}

type ResponseErr

type ResponseErr struct {
	Reason string
}

type Server

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

func NewServer

func NewServer(o Options) *Server

func (*Server) Addr

func (s *Server) Addr() string

func (*Server) HandlerChain

func (s *Server) HandlerChain(h http.Handler, secure bool) http.Handler

func (*Server) RegisterHandler

func (s *Server) RegisterHandler(pattern string, handler http.Handler, secure bool)

RegisterHandler registers into the ServeMux a handler chain that borrows its security properties from the fabhttp.Server. This method is thread safe because ServeMux.Handle() is thread safe, and options are immutable. This method can be called either before or after Server.Start(). If the pattern exists the method panics.

func (*Server) Run

func (s *Server) Run(signals <-chan os.Signal, ready chan<- struct{}) error

func (*Server) Start

func (s *Server) Start() error

func (*Server) Stop

func (s *Server) Stop() error

type TLS

type TLS struct {
	Enabled           bool
	CertFile          string
	KeyFile           string
	ClientAuth        bool
	ClientCACertFiles []string
}

func (TLS) Config

func (t TLS) Config() (*tls.Config, error)

type ViewCaller

type ViewCaller interface {
	CallView(context *ReqContext, vid string, input []byte) (interface{}, error)
}

type ViewClient added in v0.3.0

type ViewClient interface {
	StreamCallView(fid string, writer http.ResponseWriter, request *http.Request) error
	CallView(fid string, in []byte) (interface{}, error)
}

func NewViewClient added in v0.3.0

func NewViewClient(logger logger, viewManager *view.Manager) ViewClient

type WSStream added in v0.3.0

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

func NewWSStream added in v0.3.0

func NewWSStream(l logger, writer http.ResponseWriter, request *http.Request) (*WSStream, error)

func (*WSStream) Close added in v0.3.0

func (c *WSStream) Close() error

func (*WSStream) Read added in v0.3.0

func (c *WSStream) Read() ([]byte, error)

func (*WSStream) ReadInput added in v0.3.0

func (c *WSStream) ReadInput() ([]byte, error)

func (*WSStream) Recv added in v0.3.0

func (c *WSStream) Recv(p any) error

func (*WSStream) Send added in v0.3.0

func (c *WSStream) Send(p any) error

func (*WSStream) Write added in v0.3.0

func (c *WSStream) Write(message []byte) error

func (*WSStream) WriteResult added in v0.3.0

func (c *WSStream) WriteResult(raw []byte) error

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.
fakes
Code generated by counterfeiter.
Code generated by counterfeiter.
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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