Skip to content

biagioni84/tinted-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Clojars Project

tinted-proxy

A non-transparent proxy for ring. Uses http-kit client to make requests. It can act as a transparent proxy (see https://github.com/tailrecursion/ring-proxy for an alternative).

Dependency

[tinted-proxy "0.1.0-SNAPSHOT"]

Usage

(ns your-ns
  (:require [tinted-proxy.core :refer [wrap-tinted-proxy]]))
(def app
  (-> routes
      (wrap-tinted-proxy  "/postman" "http://www.postman-echo.com"
                    :update-req-body-fn (fn [req] (str (:body req) "append to body" ) )
                    :update-req-headers-fn #(:headers (assoc-in % [:headers "token"] "t"))
                    :update-resp-body-fn #(str (:body %) "append to response")
                    :update-resp-headers-fn #(dissoc (:headers %) :content-type)
                          )
      (wrap-tinted-proxy "/google" "http://www.google.com") ;; transparent proxy
      )
      )

Signatures

(defn wrap-tinted-proxy
  [handler base-path uri-build-fn & {:keys [update-req-body-fn update-req-headers-fn
                                            update-resp-body-fn update-resp-headers-fn]}]
                                            )
base-path string
uri-build-fn remote-url(string) | req->url(string)
 
optionals
---------
:update-req-body-fn     request->body(string)
:update-req-headers-fn  request->headers(map)
:update-resp-body-fn    response->body(string)
:update-resp-headers-fn response->headers(map)

About

HTTP proxy ring middleware

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published