http_util

package module
v0.0.0-...-e66126e Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2021 License: MIT Imports: 14 Imported by: 0

README

chef

before you can serve, you need a chef

⚠️ lots of development going on. ⚠️

CI go report GoDoc Coverage license

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrConfigNotJSON = errors.New("config file not JSON")

errors declarations

Functions

func PushFiles

func PushFiles(w http.ResponseWriter, files ...string) error

PushFiles takes an http.ResponseWriter and a variadic amount of file strings the function will iterate through each file and performa an HTTP/2 Push if HTTP/2 is supported AND if the files are valid. Otherwise, will return error

func RedirectHTTPS

func RedirectHTTPS(httpsHost string) func(http.ResponseWriter, *http.Request)

RedirectHTTPS can redirect all http traffic to corresponding https addresses

Types

type Server

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

Server ...

func NewServer

func NewServer(cfg ServerConfig, r *mux.Router) *Server

NewServer ...

func (*Server) Quit

func (srv *Server) Quit() error

Quit sends closes the server quit channel if the server is running signaling the server to begin shutting down if the server is not running, Quit will return an error

func (*Server) Run

func (srv *Server) Run(running chan struct{})

Run starts the running loop of the server and will fire a message to running once running has "fully begun"

type ServerConfig

type ServerConfig struct {
	Host         string `json:"host"`
	Port         string `json:"port"`
	IP           string `json:"IP"`
	ChooseIP     bool   `json:"chooseIP"`
	HTTPS        bool   `json:"secure"`
	DebugLog     bool   `json:"debugLog"`
	CacheMaxAge  int    `json:"cacheMaxAge"`
	ShutdownCode int    `json:"shutdownCode"`
	UserShutdown bool   `json:"userShutdown"`
	CertFile     string `json:"certFile"`
	KeyFile      string `json:"keyFile"`
	RootCA       string `json:"rootCA"`
}

ServerConfig is the general struct holds parsed JSON config info

func LoadConfig

func LoadConfig(filename string) (ServerConfig, error)

LoadConfig returns a config struct given a valid config.json file

func (*ServerConfig) Print

func (cfg *ServerConfig) Print()

Print provides a pretty formatted print of a ServerConfig

Jump to

Keyboard shortcuts

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