This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
JISQueueing/server/server.go

36 lines
1.0 KiB
Go

package server
import (
"JISQueueing/server/socket"
"net/http"
"github.com/gorilla/mux"
)
//NewServerMux creates a new http handler object handling API requests
func NewServerMux(debug bool) http.Handler {
router := mux.NewRouter()
router.NotFoundHandler = http.HandlerFunc(NotFound)
postRouter := router.Methods("POST").PathPrefix("/api").Subrouter()
postRouter.HandleFunc("/login", Login)
postRouter.HandleFunc("/logout", Logout)
socketRouter := router.PathPrefix("/ws").Subrouter()
socketRouter.HandleFunc("/display", socket.DisplaySocket)
socketRouter.HandleFunc("/kiosk", socket.KioskSocket)
socketRouter.HandleFunc("/staff", socket.StaffSocket)
router.PathPrefix("/api").Handler(http.HandlerFunc(NotFound))
2020-01-31 03:03:02 +07:00
router.PathPrefix("/static").Handler(http.FileServer(http.Dir("./static")))
router.PathPrefix("/").HandlerFunc(indexHandler)
2020-01-31 03:24:23 +07:00
socket.StartRedisServer("10.1.3.100:6379")
return router
}
func indexHandler(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "./static/index.html")
}