31 lines
910 B
Go
31 lines
910 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
|
|
ctrlrs "git.kealoha.me/lks/lenslocked/controllers"
|
|
"github.com/go-chi/chi/v5"
|
|
"github.com/go-chi/chi/v5/middleware"
|
|
)
|
|
|
|
func notFoundHandler(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "text/html; charset=utf8")
|
|
w.WriteHeader(http.StatusNotFound)
|
|
fmt.Fprint(w, "404 page not found")
|
|
}
|
|
|
|
func main() {
|
|
var usersCtrlr ctrlrs.Users = ctrlrs.FromStaticTemplate("signup.gohtml", "tailwind.gohtml")
|
|
r := chi.NewRouter()
|
|
r.Use(middleware.Logger)
|
|
r.Get("/", ctrlrs.StaticTemplate("home.gohtml", "tailwind.gohtml"))
|
|
r.Get("/contact", ctrlrs.StaticTemplate("contact.gohtml", "tailwind.gohtml"))
|
|
r.Get("/faq", ctrlrs.FAQ("faq.gohtml", "tailwind.gohtml"))
|
|
r.Get("/signup", usersCtrlr.New)
|
|
r.Post("/signup", usersCtrlr.Create)
|
|
r.NotFound(notFoundHandler)
|
|
fmt.Println("Starting the server on :3000...")
|
|
http.ListenAndServe(":3000", r)
|
|
}
|