-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathapp.go
27 lines (21 loc) · 807 Bytes
/
app.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
package web
import (
"fmt"
"net/http"
"github.com/servntire/servntire-demo/web/controllers"
)
func Serve(app *controllers.Application) {
fs := http.FileServer(http.Dir("web/assets"))
http.Handle("/assets/", http.StripPrefix("/assets/", fs))
http.HandleFunc("/home.html", app.HomeHandler)
http.HandleFunc("/query.html", app.QueryHandler)
http.HandleFunc("/create.html", app.CreateHandler)
http.HandleFunc("/update.html", app.UpdateHandler)
http.HandleFunc("/history.html", app.HistoryHandler)
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/home.html", http.StatusTemporaryRedirect)
})
fmt.Println("Listening (https://localhost:3000/) ...")
http.ListenAndServe(":3000", nil)
//http.ListenAndServeTLS(":443", "server.crt", "server.key", nil)
}