magmise/api/main.go

25 lines
511 B
Go
Raw Normal View History

2022-09-09 06:10:34 +00:00
package main
import (
"magmise/controllers"
"magmise/models"
"net/http"
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
)
func main() {
2022-09-10 13:21:20 +00:00
models.Store()
2022-09-09 06:10:34 +00:00
models.Init()
var user controllers.User
r := chi.NewRouter()
r.Use(middleware.Logger)
r.Handle("/*", http.FileServer(http.Dir("/api/www")))
r.Get("/user/{username}", user.Get)
r.Post("/user/{username}", user.Create)
2022-09-10 13:21:20 +00:00
r.Post("/login", controllers.Login)
r.Post("/logout", controllers.Logout)
2022-09-09 06:10:34 +00:00
http.ListenAndServe(":8080", r)
}