Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

path_router

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

path_router

  • 0.0.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

path_router

HTTP routing by URL path, built on the excellent ProxyMachine by the GitHub guys.

GitHub uses ProxyMachine to service millions of git connections every day.

Install

gem install path_router  # installs path_router and proxymachine
path_router init         # creates example path_router.rb
vim path_router.rb       # specify your backends and URL patterns
path_router              # fire it up, optionally with -h host and -p port

Routes

See example_path_router.rb to get the general idea.

PathRouter::Router.instance.reset.tap do |r|

  r.backends = {
    rails:  "127.0.0.1:3000", # default
    static: "127.0.0.1:8080",
    wordpress: "10.0.0.1:80",
  }

  r.connect :static,
    %r{^/robots.txt},
    %r{^/(?:images|stylesheets|javascripts)/}

  r.connect :wordpress,
    %r{^/blog/},
    %r{^/feed}

end

The only non-obvious point is that the first backend in the hash is the default catch-all. Ruby 1.8 users get random default backend; think of it as an easter egg ;)

Tests

$ rspec spec/*_spec.rb

PathRouter::Router
  routes by specified patterns
  defaults to first backend for unmatched requests

Finished in 0.00056 seconds
2 examples, 0 failures

Meh.

(c) 2011 Paul Annesley, MIT licence.

FAQs

Package last updated on 17 Jun 2011

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc