Giter VIP home page Giter VIP logo

ring-request-proxy's Introduction

Ring-Request-Proxy

A Clojure library for proxying requests in ring applications.

CircleCI

Installation

Clojars Project

Usage

(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"}})))

; Handler format: Responds with 404 when request can't be forwarded
(def app (proxy/proxy-request {:identifer-fn :server-name
                               :host-fn (fn [server-name] (if (.startsWith server-name "cool")
                                                              "http://my-internal-server"
                                                              nil))}))

Options

  • identifier-fn: Maps the request to an identifier that will be be used by host-fn
  • host-fn: Maps the result of identifier-fn (or the request if none provided) to the host that will receive the request. If a falsy value is returned, the request will not be forwarded.

The proxy middleware is responsible for forwarding requests to another server. If the request cannot be forwarded, the request can either receive a default response or continue the request through the delegation chain.

License

Copyright © 2015 Funding Circle

Distributed under the BSD 3-Clause License.

ring-request-proxy's People

Contributors

aprobus avatar mongey avatar princesspanda avatar sgerrand avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.