Skip to content

Commit

Permalink
Add slash to gateway-url if missing (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdemare authored Sep 19, 2024
1 parent b81e181 commit b4c8b64
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/nl/surf/eduhub/validator/service/main.clj
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@
[ring.middleware.json :refer [wrap-json-response]]))

(defn validate-endpoint [endpoint-id {:keys [gateway-url gateway-basic-auth ooapi-version] :as _config}]
{:pre [gateway-url]}
(log/info (str "validating endpoint: " endpoint-id " - gateway-url: " gateway-url))
(try
(let [response (http/get (str gateway-url "courses")
(let [response (http/get (str gateway-url (if (.endsWith gateway-url "/") "" "/") "courses")
{:headers {"x-route" (str "endpoint=" endpoint-id)
"accept" (str "application/json; version=" ooapi-version)
"x-envelope-response" "false"}
Expand Down
2 changes: 1 addition & 1 deletion test/nl/surf/eduhub/validator/service/main_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
[clojure.test :refer [deftest is]]
[nl.surf.eduhub.validator.service.main :as main]))

(def app (main/wrap-validator main/app-routes {}))
(def app (main/wrap-validator main/app-routes {:gateway-url "http://gateway.dev.surf.nl"}))

(deftest test-validate-correct
(with-redefs [http/request (fn [_] {:status 200 :body "mocked response"})]
Expand Down

0 comments on commit b4c8b64

Please sign in to comment.