0.0
Low commit activity in last 3 years
No release in over a year
Angus-router is a powerful router for your next generation of awesome Rack applications. Just throw your shit into angus-router and run away.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 1.5
 Project Readme

angus-router

A router for Rack applications.

While it can be used as a micro-framework, it's primarily and focused purpose is http request routing.

angus-router doesn't handle unregisterd routes, it doesn't provide a template rendering mechanism, and so on. Those features should be fulfilled at framework level.

Usage

Routes are registered with #on method.

router.on(:get, '/hello') do
  [200, {}, ['Hello']]
end

#route receives a Rack environment, lookups for a route matching the request's path and invokes the corresponding block.

router.route(env)

If no matching registered route, a NotImplementedError is raised.

Supported HTTP methods:

  • get
  • post
  • put
  • delete
  • head
  • options
  • patch
  • trace

Usage sample

# config.ru
require 'angus-router'

router = Angus::Router.new

router.on(:get, '/') do
  [200, {}, ['Index Page']]
end

router.on(:get, '/hello') do
  [200, {}, ['Hello']]
end

router.on(:get, '/hello/:dude') do |env, params|
  [200, {}, ["Hello #{params[:dude]}!"]]
end

run ->(env) { router.route(env) }

Installation

Install angus-router as a gem.

gem install angus-router