Documentation ¶
Overview ¶
Package handlers defines handlers for all of the endpoints accessible from the core server.
Index ¶
- Variables
- func Playground(title string, endpoint string) http.HandlerFunc
- type Auth
- func (a *Auth) AddPlugin(ctx context.Context, pluginURL string) (string, error)
- func (a *Auth) AllowOriginFunc(origin string) bool
- func (a *Auth) AuthorizeAdminToken(ctx context.Context) error
- func (a *Auth) AuthorizePluginToken(ctx context.Context) error
- func (a *Auth) CreateAdminToken(ctx context.Context) (string, error)
- func (a *Auth) Handler(next http.Handler) http.Handler
- func (a *Auth) RemovePlugin(ctx context.Context, apiToken string) (bool, error)
- type InitPayloadGetter
- type MapHandler
Constants ¶
This section is empty.
Variables ¶
var AuthError = errors.New(
"Unauthorized: 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 ¶
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) AddPlugin ¶
AddPlugin registers the provided plugin URL in the system and returns the token that the plugin can use to make requests. If the plugin URL cannot be parsed, it fails to create a token and returns an error.
func (*Auth) AllowOriginFunc ¶
AllowOriginFunc returns true only if the origin is referenced by any URL of the registered plugins.
func (*Auth) AuthorizeAdminToken ¶
AuthorizeAdminToken checks to make sure that the provided admin token is valid and is authorized to make admin-level requests.
func (*Auth) AuthorizePluginToken ¶
AuthorizePluginToken checks to make sure that the provided plugin token is valid and is authorized to make plugin-level requests.
func (*Auth) CreateAdminToken ¶
CreateAdminToken returns a persistent token that is authorized to not only the same requests that plugins can make, but also register or unregister plugins.
func (*Auth) Handler ¶
Handler returns a handler that serves cross-origin requests and pulls authentication data from incoming requests.
func (*Auth) RemovePlugin ¶
RemovePlugin unregisters the plugin corresponding to this specific apiToken. It will return success even if the apiToken is no longer registered, provided that this token is still a valid token. If all plugins corresponding to a particular origin are removed, this origin will no longer be allowed in the CORS mechanism.
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 (*MapHandler) ServeHTTP ¶
func (h *MapHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP serves maps for the handler