handlers

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package handlers defines handlers for all of the endpoints accessible from the core server.

Index

Constants

This section is empty.

Variables

View Source
var ErrAuth = errors.New(
	"unauthorized error: the request lacks valid authentication credentials for the target resource",
)

Functions

func Playground

func Playground(title string, endpoint string) http.HandlerFunc

Types

type Auth

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

Auth provides a middleware handler that handles cross-origin requests and pulling of authentication from incoming requests. It also handles the registration and deregistration of plugins and updates its authorizer methods accordingly.

func NewAuth

func NewAuth(cp *config.Provider, l *zap.Logger) (*Auth, error)

NewAuth creates a new instance of Auth. InitPayloadGetter provides a way to grab credentials from the context when the connection is made via Websockets.

func (*Auth) AllowOriginFunc

func (a *Auth) AllowOriginFunc(origin string) bool

AllowOriginFunc returns true only if the origin is referenced by any URL of the registered plugins.

func (*Auth) AuthorizePluginToken

func (a *Auth) AuthorizePluginToken(ctx context.Context) error

AuthorizePluginToken checks to make sure that the provided plugin token is valid and is authorized to make plugin-level requests.

func (*Auth) GetRegisteredPlugins

func (a *Auth) GetRegisteredPlugins() map[string]PluginInfo

GetRegisteredPlugins returns a copy of the map containing all the plugins and their API tokens.

func (*Auth) Handler

func (a *Auth) Handler(next http.Handler) http.Handler

Handler returns a handler that serves cross-origin requests and pulls authentication data from incoming requests.

func (*Auth) RefreshConfig

func (a *Auth) RefreshConfig() error

RefreshConfig will read the configuration from the config provider and add and remove plugins as necessary. Any preexisting plugins will retain the same ID and apiToken

func (*Auth) WebsocketInitFunc

func (a *Auth) WebsocketInitFunc(ctx context.Context, payload transport.InitPayload) (context.Context, error)

type InitPayloadGetter

type InitPayloadGetter func(context.Context) transport.InitPayload

InitPayloadGetter provides an alternate method of retrieving credentials for when the token cannot be sent via HTTP headers (basically the case of websockets)

type MapHandler

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

MapHandler serves requests for map images. It will attempt to serve them from disk first, downloading from xivapi if necessary. Users are subject to Client IP based rate limiting.

Usage:
GET /maps/{map_id} -> Returns an image with content type image/png or
image/jpg

Example:
GET /maps/123 -> 200 OK, image/png
GET /maps/1234 -> 404 Not Found

func NewMapHandler

func NewMapHandler(prefix string, c config.Config, l *zap.Logger) *MapHandler

NewMapHandler creates a new MapHandler

prefix is the path to this handler.

func (*MapHandler) ServeHTTP

func (h *MapHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves maps for the handler

type PluginInfo

type PluginInfo struct {
	PluginID  string
	PluginURL string
	APIToken  string
}

Jump to

Keyboard shortcuts

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