webserver

package
Version: v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateServers

func CreateServers(conf Config) (map[string]http.Handler, error)

CreateServers creates the handlers needed for serving the site(s) listed in the given configuration.

func LocateConfigFile

func LocateConfigFile(basename string) string

LocateConfigFile determines where the config file should be found based on the location of the current executable

Types

type Blog

type Blog struct {
	Root         string `json:"Root"`         // Root of the blog on the web server
	Folder       string `json:"Folder"`       // Folder on disk
	HomeArticles int    `json:"HomeArticles"` // How many articles to show on the home page
	FeedArticles int    `json:"FeedArticles"` // How many articles to show in the atom feed
	FeedTitle    string `json:"FeedTitle"`    // Title of the atom feed
	Disabled     bool   // Set to true if the folder cannot be found
}

Blog represents a blog to be served

type Config

type Config struct {
	Servers []Server `json:"Servers"` // List of servers (addresses) we are serving
	Reload  bool     // Whether to reload blogs on every visit (slow - don't use in production. For local editing.)
	Log     bool     // Whether to log requests
}

Config holds the configuration of the web server

func ReadConfig

func ReadConfig(cfgFile string) (c Config)

ReadConfig reads the configuration file at the given location

type Host

type Host struct {
	Hostname     string `json:"Hostname"`     // name of host
	VDirs        []VDir `json:"VDirs"`        // virtual directories for serving static files
	Blogs        []Blog `json:"Blogs"`        // virtual directories for serving dynamic blogs
	PlayEnabled  bool   `json:"PlayEnabled"`  // whether running go code from the browser is enabled
	NativeClient bool   `json:"NativeClient"` // whether to use a native client when running go codde
}

Host represents data about the things to server on a given hostname

type Server

type Server struct {
	Addr  string `json:"Addr"`  // address to serve on
	Hosts []Host `json:"Hosts"` // hosts at this address
}

Server respresents a given web server serving on a particular port

type VDir

type VDir struct {
	Root     string `json:"Root"`   // Root of the vdir on the web server
	Folder   string `json:"Folder"` // Folder on disk
	Disabled bool   // Set to true if the folder cannot be found
}

VDir represents a virtual directory for serving static files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to