From 5bd7273045e37ac20a0d79c03e9e9a24415b2b67 Mon Sep 17 00:00:00 2001 From: Juha Hyttinen Date: Fri, 14 Aug 2020 11:38:06 +0300 Subject: [PATCH] Added support for PathPrefix, so swagger generated APIs can be hooked into xapp-frame resthook. Change-Id: I48e5218eae7b8515c271e714ec72d6df8b10b634 Signed-off-by: Juha Hyttinen --- ci/Dockerfile | 2 +- pkg/xapp/restapi.go | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ci/Dockerfile b/ci/Dockerfile index a37b995..6e3d309 100755 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -35,7 +35,7 @@ RUN apt-get update -y \ RUN curl -s https://packagecloud.io/install/repositories/o-ran-sc/master/script.deb.sh | bash # RMR -ARG RMRVERSION=4.0.5 +ARG RMRVERSION=4.1.2 #RUN apt-get install -y rmr=${RMRVERSION} rmr-dev=${RMRVERSION} RUN wget --content-disposition https://packagecloud.io/o-ran-sc/release/packages/debian/stretch/rmr_${RMRVERSION}_amd64.deb/download.deb && dpkg -i rmr_${RMRVERSION}_amd64.deb RUN wget --content-disposition https://packagecloud.io/o-ran-sc/release/packages/debian/stretch/rmr-dev_${RMRVERSION}_amd64.deb/download.deb && dpkg -i rmr-dev_${RMRVERSION}_amd64.deb diff --git a/pkg/xapp/restapi.go b/pkg/xapp/restapi.go index 1eab7b6..922e42d 100755 --- a/pkg/xapp/restapi.go +++ b/pkg/xapp/restapi.go @@ -62,11 +62,15 @@ func (r *Router) serviceChecker(inner http.HandlerFunc) http.HandlerFunc { } func (r *Router) InjectRoute(url string, handler http.HandlerFunc, method string) *mux.Route { - return r.router.HandleFunc(url, r.serviceChecker(handler)).Methods(method) + return r.router.Path(url).HandlerFunc(r.serviceChecker(handler)).Methods(method) } func (r *Router) InjectQueryRoute(url string, h http.HandlerFunc, m string, q ...string) *mux.Route { - return r.router.HandleFunc(url, r.serviceChecker(h)).Methods(m).Queries(q...) + return r.router.Path(url).HandlerFunc(r.serviceChecker(h)).Methods(m).Queries(q...) +} + +func (r *Router) InjectRoutePrefix(prefix string, handler http.HandlerFunc) *mux.Route { + return r.router.PathPrefix(prefix).HandlerFunc(r.serviceChecker(handler)) } func (r *Router) InjectStatusCb(f StatusCb) { -- 2.16.6