appserver

package
v0.0.0-...-226ad4c Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2023 License: AGPL-3.0 Imports: 19 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 {
	ID              int      `json:"id"`
	Name            string   `json:"name,omitempty"`            // name of the app
	Icon            string   `json:"icon,omitempty"`            // icon to display
	Color           string   `json:"color,omitempty"`           // icon's color
	IsProxy         bool     `json:"isProxy"`                   // true if reverse proxy
	Host            string   `json:"host"`                      // to match against request Host header
	ForwardTo       string   `json:"forwardTo,omitempty"`       // non-empty if reverse proxy
	Serve           string   `json:"serve,omitempty"`           // non-empty if static server
	Secured         bool     `json:"secured"`                   // true if the handler is secured with auth
	Login           string   `json:"login,omitempty"`           // Basic auth login for automatic login
	Password        string   `json:"password,omitempty"`        // Basic auth password for automatic login
	OpenPath        string   `json:"openpath,omitempty"`        // Opened path on iframe preview
	Roles           []string `json:"roles,omitempty"`           // Roles allowed to access the app
	SecurityHeaders bool     `json:"securityheaders,omitempty"` // Inject security headers (CSP, STS, etc.)
	CachePattern    []string `json:"cachepattern,omitempty"`    // Cache routes corresponding to that pattern
	CacheDuration   int      `json:"cacheduration,omitempty"`   // Cache routes for seconds
}

App represents a app serving static content proxying a web server

type ByID

type ByID []App

ByID implements sort.Interface for []App based on the Id field

func (ByID) Len

func (a ByID) Len() int

func (ByID) Less

func (a ByID) Less(i, j int) bool

func (ByID) Swap

func (a ByID) Swap(i, j int)

type Server

type Server struct {
	Mu sync.RWMutex // guards the fields below

	Apps []*app
	// 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, authzFromMain authzFunc) (*Server, error)

NewServer constructs a Server that reads apps from file

func (*Server) AddApp

func (s *Server) AddApp(w http.ResponseWriter, req *http.Request)

AddApp adds an app

func (*Server) DeleteApp

func (s *Server) DeleteApp(w http.ResponseWriter, req *http.Request)

DeleteApp adds an app

func (*Server) LoadApps

func (s *Server) LoadApps() error

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

func (*Server) ProcessApps

func (s *Server) ProcessApps(w http.ResponseWriter, req *http.Request)

ProcessApps processes apps regarding of HTTP method

func (*Server) SendApps

func (s *Server) SendApps(w http.ResponseWriter, req *http.Request)

SendApps send apps as response from an http requests

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