Giter Club home page Giter Club logo

ring-middleware's Introduction

ring-middleware

This project is adapted from tailrecursion's ring-proxy middleware, and is meant for use with the Trapperkeeper Jetty9 Webservice.

Usage

To use ring-middleware, include the following dependency in your project.clj file:

[puppetlabs/ring-middleware "0.1.2"]

This project provides a single function, wrap-proxy, with the following signature:

(wrap-proxy [handler proxied-path remote-uri-base & [http-opts])

This function returns a ring handler that, when given a URL with a certain prefix, proxies the request to a remote URL specified by the remote-uri-base argument.

The arguments are as follows:

  • handler: A ring-handler that will be used if the provided url does not begin with the proxied-path prefix
  • proxied-path: The URL prefix of all requests that are to be proxied
  • remote-uri-base: The base URL that you want to proxy requests with the proxied-path prefix to
  • http-opts: An optional list of options for an http client. This is used by the handler returned by wrap-proxy when it makes a proxied request to a remote URI. For a list of available options, please see the options defined for clj-http-client.

For example, the following:

(wrap-proxy handler "/hello-world" "http://localhost:9000/hello")

would return a ring handler that proxies all requests with URL prefix "/hello-world" to http://localhost:9000/hello.

Proxy Redirect Support

By default, all proxy requests using wrap-proxy will follow any redirects, including on POST and PUT requests. To allow redirects but restrict their use on POST and PUT requests, set the :force-redirects option to false in the http-opts map. To disable redirect following on proxy requests, set the :follow-redirects option to false in the http-opts map. Please not that if proxy redirect following is disabled, you may have to disable it on the client making the proxy request as well if the location returned by the redirect is relative.

SSL Support

wrap-proxy supports SSL. To add SSL support, you can set SSL options in the http-opts map as you would in a request made with clj-http-client. Simply set the :ssl-cert, :ssl-key, and :ssl-ca-cert options in the http-opts map to be paths to your .pem files.

ring-middleware's People

Contributors

mslilah avatar cprice404 avatar pcarlisle avatar

Watchers

James Cloos 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.