Code Monkey home page Code Monkey logo

rack-redirect's Introduction

Minimal rack-based HTTP redirect

This rack app to provide a minimal, basic HTTP redirect. It can be deployed straight to any cloud platform.

The original requirement was to allow an old URL to continue working for users that had it in their bookmarks, but with the caveat we needed also the path and any potential query params to be propagated to the new (target) domain.

An S3 / Route 53 based solution would have only allowed us to redirect the domain, but not the path nor query params.

How to use it

Deploy the master branch to any cloud provider with support for Ruby/Rack, for example Heroku.

Configure the target URL and, optionally, the redirect HTTP status code, with the following ENV variables:

  REDIRECT_TARGET, for example, https://example.com
  REDIRECT_STATUS, by default if not present, will be 302

How to run locally

Clone the repo and install, if needed, bundler, and the gems. Then run the server:

  • REDIRECT_TARGET=https://example.com bundle exec rackup

or, if you want to change the default port:

  • REDIRECT_TARGET=https://example.com bundle exec rackup -p 9191

Then just go to a browser or use curl -I http://localhost:9191 (change the port accordingly).

How to run the tests

$ bundle exec rspec
......

Finished in 0.01354 seconds (files took 0.08652 seconds to load)
6 examples, 0 failures

rack-redirect's People

Contributors

dependabot[bot] avatar zheileman avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

uk-gov-mirror

rack-redirect's Issues

User access removed, access is now via a team

Hi there

This user had Direct Member access to this repository and access via a team.

Access is now only via a team.

If you have any questions, please post in #ask-operations-engineering on Slack.

This issue can be closed.

Default branch is not main

Hi there
The default branch for this repository is not set to main
See repository settings/settings/branches to rename the default branch to main and ensure the Branch protection rules is set to main as well
See the repository standards: https://github.com/ministryofjustice/github-repository-standards
See the report: https://operations-engineering-reports.cloud-platform.service.justice.gov.uk/github_repositories
Please contact Operations Engineering on Slack #ask-operations-engineering, if you need any assistance

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.