compojure-api

How do I add CORS to a compojure-api app?

你离开我真会死。 提交于 2021-02-09 09:40:16
问题 How can I add CORS to this code snippet? (def app (api {:swagger {:ui "/docs" :spec "/swagger.json"}} (GET "/route-a" [] "a") (GET "/route-b" [] "b") (GET "/route-c" [] "c"))) I would like to use https://github.com/r0man/ring-cors and have tried this, but it did not seem to do anything. I would like to see the response header contain Access-Control-Allow-Origin but it is missing. (-> (api {:swagger {:ui "/docs" :spec "/swagger.json"}} (GET "/route-a" [] "a") (GET "/route-b" [] "b") (GET "

How do I add CORS to a compojure-api app?

大憨熊 提交于 2021-02-09 09:36:17
问题 How can I add CORS to this code snippet? (def app (api {:swagger {:ui "/docs" :spec "/swagger.json"}} (GET "/route-a" [] "a") (GET "/route-b" [] "b") (GET "/route-c" [] "c"))) I would like to use https://github.com/r0man/ring-cors and have tried this, but it did not seem to do anything. I would like to see the response header contain Access-Control-Allow-Origin but it is missing. (-> (api {:swagger {:ui "/docs" :spec "/swagger.json"}} (GET "/route-a" [] "a") (GET "/route-b" [] "b") (GET "

How do I add CORS to a compojure-api app?

邮差的信 提交于 2021-02-09 09:36:16
问题 How can I add CORS to this code snippet? (def app (api {:swagger {:ui "/docs" :spec "/swagger.json"}} (GET "/route-a" [] "a") (GET "/route-b" [] "b") (GET "/route-c" [] "c"))) I would like to use https://github.com/r0man/ring-cors and have tried this, but it did not seem to do anything. I would like to see the response header contain Access-Control-Allow-Origin but it is missing. (-> (api {:swagger {:ui "/docs" :spec "/swagger.json"}} (GET "/route-a" [] "a") (GET "/route-b" [] "b") (GET "

Non-required arguments in compojure-api/schema/swagger?

我与影子孤独终老i 提交于 2019-12-07 02:57:43
问题 When I have a definition of an API like this: (POST* "/register" [] :body-params [username :- String, password :- String, name :- String] (ok))) what's the appropriate way of making name optional? Is it: (POST* "/register" [] :body-params [username :- String, password :- String, {name :- String nil}] (ok))) 回答1: As you know it uses letk plumbing notation and as far as I recall the syntax is correct but the default value should be consistent with the expected type so I'd say it should be ""

Optional query parameters (with default value) with compojure-api

一笑奈何 提交于 2019-12-06 18:31:40
问题 What is the proper way to declare an optional query parameter, with default value, when using compojure-api? One of my route elements is as follows (after reading this): (GET "/:id/descendants" [id] :return [d/CategoryTreeElement] :path-params [id :- Long] :query-params [context-type :- d/ContextType levels :- Integer {tenant :- d/Tenant :DEF_TENANT} {show-future :- Boolean false} {show-expired :- Boolean false} {show-suppressed :- Boolean false} :summary "Fetch category descendants" (ok ...)

Non-required arguments in compojure-api/schema/swagger?

时光总嘲笑我的痴心妄想 提交于 2019-12-05 08:05:37
When I have a definition of an API like this: (POST* "/register" [] :body-params [username :- String, password :- String, name :- String] (ok))) what's the appropriate way of making name optional? Is it: (POST* "/register" [] :body-params [username :- String, password :- String, {name :- String nil}] (ok))) As you know it uses letk plumbing notation and as far as I recall the syntax is correct but the default value should be consistent with the expected type so I'd say it should be "" rather than nil as (string? nil) => false (POST* "/register" [] :body-params [username :- String, password :-

Optional query parameters (with default value) with compojure-api

狂风中的少年 提交于 2019-12-04 23:45:32
What is the proper way to declare an optional query parameter, with default value, when using compojure-api ? One of my route elements is as follows (after reading this ): (GET "/:id/descendants" [id] :return [d/CategoryTreeElement] :path-params [id :- Long] :query-params [context-type :- d/ContextType levels :- Integer {tenant :- d/Tenant :DEF_TENANT} {show-future :- Boolean false} {show-expired :- Boolean false} {show-suppressed :- Boolean false} :summary "Fetch category descendants" (ok ...)) At first the boolean params where defined as the other ones (e.g. show-future Boolean ) but the