-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.go
36 lines (29 loc) · 887 Bytes
/
server.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
package main
import (
"log"
// Standard library packages
"net/http"
"github.com/44r0n/SessionManager/helpers"
"github.com/44r0n/SessionManager/repository"
"github.com/44r0n/SessionManager/controllers"
"github.com/julienschmidt/httprouter"
)
func main() {
// Instantiate a new router
r := httprouter.New()
const serverURL = "127.0.0.1:3000"
connString := helpers.GetConnString("configuration/configuration.json")
// Get a UserController instance
repo, err := repository.NewUserRepository(connString)
if err != nil {
log.Fatalf("Cannot load user repository: %v", err)
}
uc := controllers.NewUserController(repo)
r.POST("/Register", uc.Register)
r.POST("/Login", uc.Login)
r.POST("/Logout", uc.Logout)
r.POST("/Token/isValid", uc.CheckToken)
log.Printf("Starting server at %v", serverURL)
// Fire up the server
log.Fatal(http.ListenAndServe(serverURL, r))
}