Browse Source

lucifer-server: Added web serving and hookup of controllers.

login_bugfix
Gisle Aune 5 years ago
parent
commit
7634c9a0d7
  1. 12
      cmd/lucifer-server/main.go
  2. 4
      internal/config/config.go

12
cmd/lucifer-server/main.go

@ -2,7 +2,11 @@ package main
import ( import (
"log" "log"
"net/http"
"github.com/gorilla/mux"
"git.aiterp.net/lucifer/lucifer/controllers"
"git.aiterp.net/lucifer/lucifer/database/sqlite" "git.aiterp.net/lucifer/lucifer/database/sqlite"
"git.aiterp.net/lucifer/lucifer/internal/config" "git.aiterp.net/lucifer/lucifer/internal/config"
) )
@ -17,4 +21,12 @@ func main() {
if err != nil { if err != nil {
log.Fatalln("Failed to set up database:", err) log.Fatalln("Failed to set up database:", err)
} }
userController := controllers.NewUserController(sqlite.UserRepository)
router := mux.NewRouter()
userController.Mount(router, "/api/user/")
http.ListenAndServe(conf.Server.Address, router)
} }

4
internal/config/config.go

@ -11,6 +11,10 @@ type Config struct {
DB struct { DB struct {
FileName string `yaml:"file_name"` FileName string `yaml:"file_name"`
} `yaml:"db"` } `yaml:"db"`
Server struct {
Address string `yaml:"address"`
} `yaml:"server"`
} }
// Load loads the first valid config file from the list of file paths. // Load loads the first valid config file from the list of file paths.

Loading…
Cancel
Save