You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
560 B
25 lines
560 B
2 years ago
|
package main
|
||
|
|
||
|
import (
|
||
|
"github.com/go-chi/chi/v5"
|
||
|
"github.com/go-chi/chi/v5/middleware"
|
||
|
"hupeh.vip/pricing/app"
|
||
|
"log"
|
||
|
"net/http"
|
||
|
)
|
||
|
func main() {
|
||
|
app.ConfigLogger("debug.log", app.LogWhenMinute)
|
||
|
app.ConfigGormDB()
|
||
|
|
||
|
r := chi.NewRouter()
|
||
|
r.Use(middleware.Logger)
|
||
|
r.Get("/goods", app.Handler(app.GetGoodsList))
|
||
|
r.Post("/goods", app.Handler(app.CreateGoods))
|
||
|
r.Get("/goods/:id/prices", app.Handler(app.GetGoodsPrices))
|
||
|
r.Post("/goods/:id", app.Handler(app.UpdateGoods))
|
||
|
|
||
|
if err := http.ListenAndServe(":3000", r); err != nil {
|
||
|
log.Fatalln(err)
|
||
|
}
|
||
|
}
|