Initial MVP: Go + templ Tolino-optimized ebook library scaffold
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/arnef/ebooks/internal/library"
|
||||
"github.com/arnef/ebooks/internal/web"
|
||||
)
|
||||
|
||||
func main() {
|
||||
booksDir := getenv("BOOKS_DIR", "books")
|
||||
addr := getenv("ADDR", ":8080")
|
||||
|
||||
lib := library.New(booksDir)
|
||||
h := web.NewHandler(lib)
|
||||
|
||||
mux := http.NewServeMux()
|
||||
h.RegisterRoutes(mux)
|
||||
|
||||
log.Printf("ebooks server listening on %s (books dir: %s)", addr, booksDir)
|
||||
if err := http.ListenAndServe(addr, mux); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func getenv(key, fallback string) string {
|
||||
if v := os.Getenv(key); v != "" {
|
||||
return v
|
||||
}
|
||||
return fallback
|
||||
}
|
||||
Reference in New Issue
Block a user