I am developing a server to be like a sort of a proxy in Clojure, with pedestal service + lein as a base:
It's easy to code and there are many resources on how to serve a route,
however I could not find any easy way, how to have a Clojure pedestal rest
service together with forwarding routes
Example:
(ns your-ns
(:require [tailrecursion.ring-proxy :refer [wrap-proxy]]))
(def app
(-> routes
(wrap-proxy "/remote" "http://some.remote.server/remote")))
I am just not able to mix routing system from pedestal with this proxy solution, routes are different, seems like, maybe I will need to do it with a different approach
Take a look at ring-request-proxy
over here. From the docs:
(ns myapp.core
(:require [ring-request-proxy.core :as proxy])
; Middleware format: Delegates request to handler when request can't be forwarded
(def app (-> not-found-handler
(proxy/proxy-request {:identifier-fn :server-name
:host-fn {"my-server" "http://my-internal-server"}})))
You should be set it as a middleware for all routes you want to proxy.