This commit is contained in:
Evan Buss
2024-07-06 17:59:54 -04:00
parent c63b20551f
commit 7e066fafee
8 changed files with 270 additions and 130 deletions

30
server.go Normal file
View File

@@ -0,0 +1,30 @@
package main
import (
"net/http"
"os"
"github.com/evan-buss/kobo-opds-proxy/html"
)
type Server struct {
addr string
router *http.ServeMux
}
func NewServer() *Server {
port := os.Getenv("PORT")
if os.Getenv("PORT") == "" {
port = "8080"
}
router := http.NewServeMux()
router.HandleFunc("GET /{$}", handleHome())
router.HandleFunc("GET /feed", handleFeed())
router.Handle("GET /static/", http.FileServer(http.FS(html.StaticFiles())))
return &Server{
addr: ":" + port,
router: router,
}
}