-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
34 lines (25 loc) · 971 Bytes
/
Copy pathmain.go
File metadata and controls
34 lines (25 loc) · 971 Bytes
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
package main
import (
"net/http"
"github.com/ArtyomWS/GoWebCourse/controllers"
"github.com/ArtyomWS/GoWebCourse/templates"
"github.com/ArtyomWS/GoWebCourse/views"
"github.com/go-chi/chi/v5"
)
func notFoundHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content Type", "text/html")
http.Error(w, "Page Not Found", http.StatusNotFound)
}
func main() {
r := chi.NewRouter()
tpl := views.Must(views.ParseFS(templates.FS, "home.gohtml", "tailwind.gohtml"))
r.Get("/", controllers.StaticHandler(tpl))
tpl = views.Must(views.ParseFS(templates.FS, "contact.gohtml", "tailwind.gohtml"))
r.Get("/contact", controllers.StaticHandler(tpl))
tpl = views.Must(views.ParseFS(templates.FS, "faq.gohtml", "tailwind.gohtml"))
r.Get("/faq", controllers.Faq(tpl))
tpl = views.Must(views.ParseFS(templates.FS, "signup.gohtml", "tailwind.gohtml"))
r.Get("/signup", controllers.Faq(tpl))
r.NotFound(notFoundHandler)
http.ListenAndServe(":3000", r)
}