Giter Site home page Giter Site logo

singinx's Introduction

Sinatra + Nginx + Docker compose

What is this

A little playground for trying out Nginx URL rewrites.

I needed a way to rewrite incoming URLs /api/v2/foo to remove the v2 and turn it into a parameter instead version=2. At the same time, I also needed any incoming URLs /api/foo with the version already specified to be left as-is.

This might be a useful project if:

  • you need a place to spin up and test nginx configs
  • you haven't seen an nginx image used without a Dockerfile
  • you've never linked containers together using docker compose
  • you need a super simple example of sinatra app that's wired up correctly to rackup.

Update: I wrote a blog post explaining the background behind this project.

Usage

$ make serve
# lots of boring noise as software builds

in another terminal session

$ make test
# lots of boring output...

after losing several seconds of your life, you can clean up using

$ make clean

Routes and expected outcomes

Method Sinatra Nginx Params (In) Params (Out)
GET /api/v2/foo /api/foo none version=2
POST /api/v2/bar /api/bar none version=2
GET /api/foo as-is version=3 as-is
POST /api/bar as-is version=3 as-is

License

MIT

singinx's People

Contributors

booyaa avatar

Stargazers

 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.