2 @unnumbered Configuration
4 Initially @command{godlighty} has basic static files handlers (with
5 compression, HTTP preconditions are enabled of course). In the example
6 below there are nearly all default functions.
7 Also look for @file{rc/example.cfg}.
10 Hosts["example.com"] = &godlighty.HostCfg{
11 Root: "/www/example.com",
12 EdDSATLS: &godlighty.TLSCfg{
13 Cert: "/path/to/example.com.pem",
14 Key: "/path/to/example.com.key.pem",
15 CACert: "/path/to/ca.pem",
19 MIMEs: map[string]string{
20 ".special": "text/x-special-type",
25 If your keys and certificates are in single file and you use common CA
26 certificate, then it is trivial to DRY:
31 CACert = path.Join(Etc, "ca.pem")
34 func newTLSCfg(host string) *godlighty.TLSCfg {
35 return &godlighty.TLSCfg{
36 Cert: path.Join(Etc, host+".pem"),
37 Key: path.Join(Etc, host+".pem"),
43 But there are hooks that can do anything more. For example if you want
44 to run CGI script or make a redirection (FastCGI handler example is in
45 @file{rc/fcgi.example.cfg}):
50 Hooks: []godlighty.Hook{
51 func(w http.ResponseWriter, r *http.Request) bool {
52 if r.URL.Path == "/" {
53 http.Redirect(w, r, "//here.we.go/", http.StatusMovedPermanently)
58 func(w http.ResponseWriter, r *http.Request) bool {
60 Path: "/usr/local/libexec/git-core/git-http-backend",
63 "GIT_PROJECT_ROOT=" + root,
64 "GIT_HTTP_EXPORT_ALL=",
72 You can separate your configuration files and add them through
76 $ ls rc/stargrave.org.cfg
83 if.mirror.cypherpunks.ru.go
84 lists.cypherpunks.ru.go
89 $ cat rc/stargrave.org.cfg/static.go
94 func addStaticCfg(host, root string) {
95 if !path.IsAbs(root) {
96 root = path.Join(WWW, root)
98 godlighty.Hosts[host] = &godlighty.HostCfg{
100 TLS: newTLSCfg(host),
104 func addStaticListedDir(host, root string) {
105 addStaticCfg(host, root)
106 godlighty.Hosts[host].DirList = true
107 godlighty.Hosts[host].WebDAV = true
112 addStaticCfg("paster.stargrave.org", "/storage/paster/pastes")
113 addStaticCfg("www.godlighty.stargrave.org", "godlighty.stargrave.org")
114 addStaticCfg("www.nncpgo.org", "nncpgo.org")
115 addStaticListedDir("www.mds.cypherpunks.ru", "/storage/audiobook/mds")
120 There are some preexisting helpers to deal with:
130 @item rc/mime.go, rc/mime/*
131 Predefined @code{Content-Type} entries. Each file in @file{rc/mime/*}
132 has tab-separated format: file's extension, media type and optional
133 @code{c} mark, meaning that these type can be transparently compressed