appserver

package
v0.0.0-...-12912d6 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2020 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	IsProxy   bool     `json:"isProxy"`   // true if reverse proxy
	Host      string   `json:"host"`      // to match against request Host header
	ForwardTo string   `json:"forwardTo"` // non-empty if reverse proxy
	Serve     string   `json:"serve"`     // non-empty if file server
	Secured   bool     `json:"secured"`   // true if the handler is JWT secured
	Login     string   `json:"login"`     // Basic auth login for automatic login
	Password  string   `json:"password"`  // Basic auth password for automatic login
	Roles     []string `json:"roles"`     // Roles allowed to access the app
}

App represents a app serving static content proxying a web server

type Server

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

Server implements an http.Handler that acts as either a reverse proxy or a simple file server, as determined by a rule set.

func NewServer

func NewServer(file string, portFromMain int, frameSourceFromMain string, mainHostNameFromMain string, authzFromMain authzFunc) (*Server, error)

NewServer constructs a Server that reads apps from file

func (*Server) HostPolicy

func (s *Server) HostPolicy(ctx context.Context, host string) error

HostPolicy implements autocert.HostPolicy by consulting the apps list for a matching host name.

func (*Server) LoadApps

func (s *Server) LoadApps(file string) error

LoadApps tests whether file has been modified since its last invocation and, if so, loads the app set from file.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP matches the Request with a app and, if found, serves the request with the app's handler.

Jump to

Keyboard shortcuts

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