ingress

package
v0.0.0-...-25e8c23 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoggingMiddleware

func LoggingMiddleware(next http.Handler) http.Handler

Types

type Config

type Config struct {
	ApiVersion string `yaml:"apiVersion"`
	Spec       []struct {
		Host   string `yaml:"host"`
		Routes []struct {
			Path           string   `yaml:"path"`
			Methods        []string `yaml:"methods"`
			Protocol       string   `yaml:"protocol"`
			AllowAnonymous bool     `yaml:"allow_anonymous"`
			AllowedRoles   []string `yaml:"allowed_roles"`
		} `yaml:"routes"`
	} `yaml:"spec"`
}

func ParseConfig

func ParseConfig(path string) (*Config, error)

type Ingress

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

func New

func New(cfg *Config, authenticator auth.Authenticator, globalMiddleware []mux.MiddlewareFunc, apiMiddleware []mux.MiddlewareFunc) (*Ingress, error)

New create a new ingress router. The config specifies with back-ends the gateway has. This cannot be nil The authenticator is used for the /auth(/login,/logout,/register,/refresh) endpoints. globalMiddleware is a slice of middleware functions that are applied on every request that comes in apiMiddleware is a slice of middleware function that are applied on any request starting with /api/v1. (These are defined in the config).

func (*Ingress) Reload

func (i *Ingress) Reload()

func (*Ingress) ServeHTTP

func (i *Ingress) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Ingress) Use

func (i *Ingress) Use(mfw ...mux.MiddlewareFunc)

Jump to

Keyboard shortcuts

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