22 lines
419 B
Go
22 lines
419 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"magmise/controllers"
|
||
|
"magmise/models"
|
||
|
"net/http"
|
||
|
|
||
|
"github.com/go-chi/chi/v5"
|
||
|
"github.com/go-chi/chi/v5/middleware"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
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)
|
||
|
http.ListenAndServe(":8080", r)
|
||
|
}
|