go-bouquins/main.go

49 lines
784 B
Go

package main
import (
"html/template"
"log"
"net/http"
"meutel.net/meutel/go-bouquins/bouquins"
)
const (
INDEX = "/"
BOOKS = "/books"
AUTHORS = "/authors"
SERIES = "/series"
JS = "/js/"
CSS = "/css/"
)
func init() {
tpl, err := template.ParseGlob("templates/*.html")
if err != nil {
log.Fatalln(err)
}
app := &bouquins.Bouquins{
tpl,
}
assets()
router(app)
}
func assets() {
http.Handle(JS, http.FileServer(http.Dir("assets")))
http.Handle(CSS, http.FileServer(http.Dir("assets")))
}
func router(app *bouquins.Bouquins) {
http.HandleFunc(INDEX, app.IndexPage)
http.HandleFunc(BOOKS, app.BooksPage)
http.HandleFunc(AUTHORS, app.AuthorsPage)
http.HandleFunc(SERIES, app.SeriesPage)
}
func main() {
http.ListenAndServe(":9000", nil)
}