web

package
v0.0.0-...-167e9fd Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2023 License: GPL-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const ContextKeyRequestId = ContextKey("ContextKeyRequestId")
View Source
const ContextKeyRequestor = ContextKey("ContextKeyRequestor")
View Source
const ContextKeyRequestorId = ContextKey("ContextKeyRequestorId")
View Source
const GENERIC_ERROR_MESSAGE = "The request could not be processed. Contact a server admin for assistance with reviewing error details in SOC logs."

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseHandler

type BaseHandler struct {
	Host *Host
	Impl HandlerImpl
}

func (*BaseHandler) GetPathParameter

func (handler *BaseHandler) GetPathParameter(path string, paramIndex int) string

func (*BaseHandler) Handle

func (handler *BaseHandler) Handle(responseWriter http.ResponseWriter, request *http.Request)

func (*BaseHandler) ReadJson

func (handler *BaseHandler) ReadJson(request *http.Request, obj interface{}) error

func (*BaseHandler) WriteJson

func (handler *BaseHandler) WriteJson(responseWriter http.ResponseWriter, request *http.Request, statusCode int, obj interface{}) (int, error)

type BasePreprocessor

type BasePreprocessor struct {
}

func NewBasePreprocessor

func NewBasePreprocessor() *BasePreprocessor

func (*BasePreprocessor) Preprocess

func (processor *BasePreprocessor) Preprocess(ctx context.Context, req *http.Request) (context.Context, int, error)

func (*BasePreprocessor) PreprocessPriority

func (Processor *BasePreprocessor) PreprocessPriority() int

type Client

type Client struct {
	Auth ClientAuth
	// contains filtered or unexported fields
}

func NewClient

func NewClient(url string, verifyCert bool) *Client

func (*Client) FormatUrl

func (client *Client) FormatUrl(url string, path string) string

func (*Client) MockResponse

func (client *Client) MockResponse(mockResponse *http.Response, mockError error)

func (*Client) MockStringResponse

func (client *Client) MockStringResponse(body string, statusCode int, mockError error)

func (*Client) SendAuthorizedObject

func (client *Client) SendAuthorizedObject(method string, path string, obj interface{}, returnedObj interface{}) (bool, error)

func (*Client) SendAuthorizedRequest

func (client *Client) SendAuthorizedRequest(method string, path string, contentType string, reader io.Reader) (*http.Response, error)

func (*Client) SendObject

func (client *Client) SendObject(method string, path string, obj interface{}, returnedObj interface{}, auth bool) (bool, error)

func (*Client) SendRequest

func (client *Client) SendRequest(method string, path string, contentType string, reader io.Reader, auth bool) (*http.Response, error)

type ClientAuth

type ClientAuth interface {
	Authorize(request *http.Request) error
}

type Connection

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

func NewConnection

func NewConnection(wsConn *websocket.Conn, ip string) *Connection

func (*Connection) IsAuthorized

func (connection *Connection) IsAuthorized(kind string) bool

func (*Connection) UpdatePingTime

func (connection *Connection) UpdatePingTime()

type ContextKey

type ContextKey string

type HandlerImpl

type HandlerImpl interface {
	HandleNow(ctx context.Context, responseWriter http.ResponseWriter, request *http.Request) (int, interface{}, error)
}

type Host

type Host struct {
	Version string
	// contains filtered or unexported fields
}

func NewHost

func NewHost(address string, htmlDir string, timeoutMs int, version string) *Host

func (*Host) AddConnection

func (host *Host) AddConnection(wsConn *websocket.Conn, ip string) *Connection

func (*Host) AddPreprocessor

func (host *Host) AddPreprocessor(preprocessor Preprocessor) error

func (*Host) Broadcast

func (host *Host) Broadcast(kind string, obj interface{})

func (*Host) GetSourceIp

func (host *Host) GetSourceIp(request *http.Request) string

func (*Host) IsRunning

func (host *Host) IsRunning() bool

func (*Host) Preprocess

func (host *Host) Preprocess(ctx context.Context, req *http.Request) (context.Context, int, error)

func (*Host) Preprocessors

func (host *Host) Preprocessors() []Preprocessor

*

  • Returns a copy of the list of preprocessors, in their current priority order,
  • where the first preprocessor at index 0 is processed first.

func (*Host) Register

func (host *Host) Register(route string, handler HostHandler)

func (*Host) RemoveConnection

func (host *Host) RemoveConnection(wsConn *websocket.Conn)

func (*Host) Start

func (host *Host) Start()

func (*Host) Stop

func (host *Host) Stop()

type HostHandler

type HostHandler interface {
	Handle(responseWriter http.ResponseWriter, request *http.Request)
}

type Preprocessor

type Preprocessor interface {
	PreprocessPriority() int
	Preprocess(ctx context.Context, request *http.Request) (context.Context, int, error)
}

type WebSocketHandler

type WebSocketHandler struct {
	BaseHandler
}

func NewWebSocketHandler

func NewWebSocketHandler(host *Host) *WebSocketHandler

func (*WebSocketHandler) HandleNow

func (webSocketHandler *WebSocketHandler) HandleNow(ctx context.Context, writer http.ResponseWriter, request *http.Request) (int, interface{}, error)

type WebSocketMessage

type WebSocketMessage struct {
	Kind   string
	Object interface{}
}

Jump to

Keyboard shortcuts

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