mirror of
https://github.com/Floriansylvain/RenewCMS.git
synced 2026-08-19 11:43:22 +02:00
32 lines
647 B
Go
32 lines
647 B
Go
package main
|
|
|
|
import (
|
|
"GohCMS2/api"
|
|
"encoding/json"
|
|
"fmt"
|
|
"github.com/go-chi/chi/v5"
|
|
"github.com/go-chi/httplog"
|
|
"net/http"
|
|
)
|
|
|
|
func main() {
|
|
api.InitContainer()
|
|
|
|
r := chi.NewRouter()
|
|
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
|
|
msg, _ := json.Marshal(map[string]string{"message": "Hello World"})
|
|
_, _ = w.Write(msg)
|
|
})
|
|
r.Mount("/article", api.NewArticleRouter())
|
|
|
|
apiRouter := chi.NewRouter()
|
|
apiRouter.Use(httplog.RequestLogger(httplog.NewLogger("GohCMS2")))
|
|
apiRouter.Mount("/v1", r)
|
|
|
|
fmt.Println("Server starting on port 8080")
|
|
err := http.ListenAndServe(":8080", apiRouter)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|