]> Sergey Matveev's repositories - godlighty.git/blob - rc/example.cfg/blog.stargrave.org.go
Fixed example's obsolete field
[godlighty.git] / rc / example.cfg / blog.stargrave.org.go
1 // CGI example
2
3 package cfg
4
5 import (
6         "net/http"
7         "net/http/cgi"
8         "path"
9         "strings"
10
11         "go.stargrave.org/godlighty"
12         "go.stargrave.org/godlighty/rc"
13 )
14
15 func init() {
16         host := "blog.stargrave.org"
17         godlighty.Hosts[host] = &godlighty.HostCfg{
18                 Root: path.Join(WWW, host),
19                 EdDSATLS:  newTLSCfg(host),
20                 Hooks: []godlighty.Hook{
21                         func(w http.ResponseWriter, r *http.Request) bool {
22                                 var t string
23                                 if strings.HasPrefix(r.URL.Path, "/russian") {
24                                         t = "russian"
25                                 } else if strings.HasPrefix(r.URL.Path, "/english") {
26                                         t = "english"
27                                 } else if strings.HasPrefix(r.URL.Path, "/example") {
28                                         t = "example"
29                                 }
30                                 if t == "" {
31                                         return false
32                                 }
33                                 r.URL.Path = strings.TrimPrefix(r.URL.Path, "/"+t)
34                                 rc.RunCGIAndLog(host, w, r, &cgi.Handler{
35                                         Path: "/home/sgblog/sgblog",
36                                         Dir:  "/var/empty",
37                                         Env:  []string{"SGBLOG_CFG=/home/sgblog/" + t + ".hjson"},
38                                 })
39                                 return true
40                         },
41                 },
42         }
43 }