-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base url #4
Comments
Hi @yayitswei. Glad you're enjoying the library. I can't think of a way to do that automatically. In some of our client's that use remote we have ended up just using (r/defservice offer-service
(r/headers {"Content-Type" "application/json"})
(r/on-status
(200 [res]
(json/parse-string (:body res)))
(201 [res]
(json/parse-string (:body res)))
(500 [_]
(error/bomb "There was an error trying to fetch offers.")))
(r/endpoint :create-offer (str config/nginx-endpoint "/offer_data/v2/offers")
(r/method :post)
(r/on-request [req body]
(s/validate OfferCreate body)
(-> req
(assoc :body (json/generate-string body))
(merge common-opts))))) It isn't documented well but each of these macros are really just helper functions for manipulating a data structure. You could write your own functions to create the data structure that take into account a base url. |
I think what Jake says is accurate. This library was initially conceived as a CLJS client library so base paths where not in mind. Adding a helper that can set up a base path should not be difficult at https://github.com/outpace/remote/blob/master/src/outpace/remote/service.cljc#L144 Cheers |
My question is similar to to yayitswei. I have a base url and a token that I need to make configurable. This is for a service that requires the token to be in the header. I attempted to solve this with dynamic vars, but that does not work. My solution was something like this, (def ^:dynamic token "")
(defmacro with-token [new-token & body]
`(binding [token ~new-token]
~@body))
(defservice service
(headers {"X-Service" token}) ...)
I am guessing this is failing because defservice is a marco but I am not sure. |
@iwillig apologies for the late reply, I think the feature you're looking for to make something like this work is the The construction you have above will attempt to look up the value of I believe that will look something like: (defservice service
(on-request [req] (assoc-in req [:headers "X-Service"] token)) ...) |
Hi, thanks for making remote. Is there a way to add a base url to be used by all the endpoints in a service?
The text was updated successfully, but these errors were encountered: