-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
52 lines (43 loc) · 1.03 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"fmt"
"net/http"
"github.com/go-chi/chi/v5"
"github.com/teksrc/lenslocked/controllers"
"github.com/teksrc/lenslocked/templates"
"github.com/teksrc/lenslocked/views"
)
func main() {
r := chi.NewRouter()
r.Get("/", controllers.StaticHandler(views.Must(
views.ParseFS(
templates.FS,
"home.gohtml", "tailwind.gohtml",
)),
))
r.Get("/contact", controllers.StaticHandler(
views.Must(views.ParseFS(
templates.FS,
"contact.gohtml", "tailwind.gohtml",
)),
))
r.Get("/faq", controllers.FAQ(
views.Must(views.ParseFS(
templates.FS,
"faq.gohtml", "tailwind.gohtml",
)),
))
usersC := controllers.Users{
}
usersC.Templates.New = views.Must(views.ParseFS(
templates.FS,
"signup.gohtml", "tailwind.gohtml",
))
r.Get("/signup", usersC.New)
r.Post("/signup", usersC.Create)
r.NotFound(func(w http.ResponseWriter, r *http.Request) {
http.Error(w, "Page not found", http.StatusNotFound)
})
fmt.Println("Starting the server on :3000...")
http.ListenAndServe(":3000", r)
}