chrome

package
v7.0.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2023 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

package chrome provides a simple interface for enforcing chromeentication in HTTP handlers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterChrome

func RegisterChrome(ctx context.Context, scheme string, init_func ChromeInitializationFunc) error

RegisterChrome registers 'scheme' as a key pointing to 'init_func' in an internal lookup table used to create new `Chrome` instances by the `NewChrome` method.

func Schemes

func Schemes() []string

Schemes returns the list of schemes that have been registered.

Types

type Chrome

type Chrome interface {
	// WrapHandler wraps a `http.Handler` with any implementation-specific middleware.
	WrapHandler(http.Handler, string) http.Handler
	AppendStaticAssetHandlers(*http.ServeMux) error
	AppendStaticAssetHandlersWithPrefix(*http.ServeMux, string) error
}

type Chrome is a simple interface for enforcing chromeentication in HTTP handlers.

func NewChrome

func NewChrome(ctx context.Context, uri string) (Chrome, error)

NewChrome returns a new `Chrome` instance configured by 'uri'. The value of 'uri' is parsed as a `url.URL` and its scheme is used as the key for a corresponding `ChromeInitializationFunc` function used to instantiate the new `Chrome`. It is assumed that the scheme (and initialization function) have been registered by the `RegisterChrome` method.

func NewNoneChrome

func NewNoneChrome(ctx context.Context, uri string) (Chrome, error)

NewNoneChrome implements the Chrome interface that always returns a "not authorized" error. configured by 'uri' which is expected to take the form of:

none://

type ChromeInitializationFunc

type ChromeInitializationFunc func(ctx context.Context, uri string) (Chrome, error)

ChromeInitializationFunc is a function defined by individual chrome package and used to create an instance of that chrome

type NoneChrome

type NoneChrome struct {
	Chrome
}

type NoneChrome implements the Chrome interface that always returns a "not authorized" error.

func (*NoneChrome) AppendStaticAssetHandlers

func (c *NoneChrome) AppendStaticAssetHandlers(*http.ServeMux) error

func (*NoneChrome) AppendStaticAssetHandlersWithPrefix

func (c *NoneChrome) AppendStaticAssetHandlersWithPrefix(mux *http.ServeMux, prefix string) error

func (*NoneChrome) WrapHandler

func (c *NoneChrome) WrapHandler(h http.Handler, path string) http.Handler

WrapHandler returns 'h' unchanged.

Jump to

Keyboard shortcuts

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