2017-05-03 06:52:14 +02:00
|
|
|
// Package that contains all api routes of this microservice
|
2017-03-25 16:09:17 +01:00
|
|
|
package http
|
|
|
|
|
|
|
|
import (
|
|
|
|
goji "goji.io"
|
|
|
|
"goji.io/pat"
|
2017-04-28 12:05:58 +02:00
|
|
|
|
|
|
|
"github.com/genofire/hs_master-kss-monolith/lib/http"
|
|
|
|
"github.com/genofire/hs_master-kss-monolith/runtime"
|
2017-03-25 16:09:17 +01:00
|
|
|
)
|
|
|
|
|
2017-05-03 06:52:14 +02:00
|
|
|
// Function to bind all api routes to the webserver
|
2017-03-25 16:09:17 +01:00
|
|
|
func BindAPI(router *goji.Mux) {
|
2017-03-30 18:43:18 +02:00
|
|
|
router.HandleFunc(pat.Get("/api/status"), status)
|
2017-04-03 14:59:43 +02:00
|
|
|
router.HandleFunc(pat.Get("/api/good/:productid"), listGoods)
|
2017-05-12 10:54:05 +02:00
|
|
|
router.HandleFunc(pat.Get("/api/good/availablity/:productid"), getGoodAvailability)
|
|
|
|
router.HandleFunc(pat.Get("/api/good/freshness/:goodid"), getGoodFreshness)
|
2017-04-28 12:05:58 +02:00
|
|
|
router.HandleFunc(pat.Post("/api/good/:productid"), http.PermissionHandler(addGood, runtime.HasPermission, runtime.PermissionCreateGood))
|
2017-05-18 23:42:00 +02:00
|
|
|
router.HandleFunc(pat.Delete("/api/good/:goodid"), http.PermissionHandler(delGood, runtime.HasPermission, runtime.PermissionDeleteGood))
|
2017-06-05 14:30:31 +02:00
|
|
|
|
|
|
|
router.HandleFunc(pat.Post("/api/goods/locking"), lockGoods)
|
|
|
|
router.HandleFunc(pat.Delete("/api/goods/locking"), releaseGoods)
|
2017-03-25 16:09:17 +01:00
|
|
|
}
|