29 lines
822 B
Go
29 lines
822 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() {
|
|
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", ctrlrs.StaticTemplate("signup.gohtml", "tailwind.gohtml"))
|
|
r.NotFound(notFoundHandler)
|
|
fmt.Println("Starting the server on :3000...")
|
|
http.ListenAndServe(":3000", r)
|
|
}
|