controller

package
v0.0.0-...-2062ed6 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2020 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package controller holds all handlers and handler functions as well as necessary infrastructure for session management and security

Parse all templates once and make them globally available

Index

Constants

View Source
const Base = "src/github.com/geobe/https-proxy"

the relative location of project files

View Source
const S_PROXY = "Proxy-App-Session"

keys for the session store

Variables

This section is empty.

Functions

func GetHttpPort

func GetHttpPort() string

func GetLogInOutPath

func GetLogInOutPath() string

func GetProxies

func GetProxies() map[string]*httputil.ReverseProxy

func GetTargets

func GetTargets() map[string][]string

func GetTlsPort

func GetTlsPort() string

func GetUsers

func GetUsers() map[string]model.User

func InitRouter

func InitRouter() *mux.Router

func IsStealthMode

func IsStealthMode() bool
func MakeLinks(userName string) (map[string]string, map[string]string)

* create two maps<br> links: random key -> human readable link<br> ref: random key -> target key

func RedirectHTTP

func RedirectHTTP(w http.ResponseWriter, r *http.Request)

RedirectHTTP is an HTTP handler (suitable for use with http.HandleFunc) that responds to all requests by redirecting to the same URL served over HTTPS. It should only be invoked for requests received over HTTP.

func RequestLogger

func RequestLogger(h http.Handler) http.Handler

RequestLogger uses logRequest function to log request info to log output

func ResourceBase

func ResourceBase(projectBase string) string

* return base directory of static resources like styles, images or templates projectBase base path of the project

func SessionChecker

func SessionChecker(h http.Handler) http.Handler

SessionChecker filter checks if there is a valid session, i.e if someone is logged in

func SessionStore

func SessionStore() sessions.Store

* accessor for the gorilla session store

func SetupConfig

func SetupConfig(cfgfile string)

* set up viper configuration lib and initialize data from configuration file

func Templates

func Templates(projectBase string)

func Views

func Views() *template.Template

Types

type HandlerSwitch

type HandlerSwitch struct {
	Mux          http.Handler
	Redirect     http.Handler
	AllowedHosts []string
}

struct to hold different route multiplexer. Internal calls from the same local net will be directly routed by Mux, else redirect to Redirect that shall redirect to HTTPS

func (*HandlerSwitch) ServeHTTP

func (h *HandlerSwitch) ServeHTTP(w http.ResponseWriter, r *http.Request)

Handler function that redirects access from external internet to redirect handler. Local is directly routed to MUX.

type Refmap

type Refmap struct {
	Refs, Targets map[string]string
}

func NewRefmap

func NewRefmap(r, t map[string]string) *Refmap

type Viewmodel

type Viewmodel map[string]interface{}

map transports values from go code to templates

Jump to

Keyboard shortcuts

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