diff options
Diffstat (limited to 'roseh.moe.go')
| -rw-r--r-- | roseh.moe.go | 34 |
1 files changed, 7 insertions, 27 deletions
diff --git a/roseh.moe.go b/roseh.moe.go index 8ca8872..5d6d2d5 100644 --- a/roseh.moe.go +++ b/roseh.moe.go @@ -8,23 +8,19 @@ import ( "io" "log" "net/http" - "net/http/httputil" - "net/url" "strings" "time" ) var ( - port = flag.Int("port", 42069, "port to listen on") - https = flag.Bool("https", false, "use https") + port = flag.Int("port", 42069, "port to listen on") serverStartTime = time.Now() ) var ( //go:embed templates/404.html.template - notFoundString string - + notFoundString string notFoundTemplate = template.Must(template.New("notFound").Parse(notFoundString)) ) @@ -40,15 +36,11 @@ func notFound(w http.ResponseWriter, r *http.Request) { var ( //go:embed templates/outline.html.template - outlineString string - + outlineString string outlineTemplate = template.Must(template.New("outline").Parse(outlineString)) -) -var ( //go:embed templates/index.html.template - indexString string - + indexString string indexTemplate = template.Must(template.Must(outlineTemplate.Clone()).New("body").Parse(indexString)) ) @@ -60,8 +52,7 @@ func index(w http.ResponseWriter, _ *http.Request) { var ( //go:embed templates/pong.html.template - pongString string - + pongString string pongTemplate = template.Must(template.New("pong").Parse(pongString)) ) @@ -96,23 +87,12 @@ func main() { flag.Parse() http.HandleFunc("GET /pong", pong) - jellyfinURL, err := url.Parse("http://localhost:8096") - if err != nil { - log.Fatalf("Jellyfin URL: %s", err) - } - http.Handle("/cinema/", httputil.NewSingleHostReverseProxy(jellyfinURL)) http.HandleFunc("GET /static/", static) http.HandleFunc("GET /favicon.ico", favicon) http.HandleFunc("GET /{$}", index) - notFoundMux := http.NewServeMux() - notFoundMux.HandleFunc("GET /", notFound) - http.Handle("/", notFoundMux) + http.HandleFunc("GET /", notFound) addr := fmt.Sprintf(":%d", *port) log.Printf("Listening on %q", addr) - if *https { - log.Fatal(http.ListenAndServeTLS(addr, "/var/lib/acme/roseh.moe/cert.pem", "/var/lib/acme/roseh.moe/key.pem", nil)) - } else { - log.Fatal(http.ListenAndServe(addr, nil)) - } + log.Fatal(http.ListenAndServe(addr, nil)) } |
