restructuring

This commit is contained in:
2025-01-02 16:21:02 +01:00
parent f80889ff95
commit fbca771479
6 changed files with 66 additions and 54 deletions

View File

@@ -1,20 +1,21 @@
package main
import (
"crowsnest/internal/routes"
"log"
"net/http"
)
type App struct {}
func main() {
// routes
http.HandleFunc("GET /", routes.Index)
http.HandleFunc("POST /up/search", routes.UpSearch)
app := &App{}
// serve files from the "static" directory
fs := http.FileServer(http.Dir("assets/static"))
http.Handle("GET /static/", http.StripPrefix("/", fs))
server := http.Server{
Addr: ":8080",
Handler: app.routes(),
}
// start server
http.ListenAndServe(":8080", nil)
server.ListenAndServe()
log.Println("server started, listening on :8080")
}