Coder Social home page Coder Social logo

travel's Introduction

Traversal-like Dynamic HTTP Routing in Go

Travel is an HTTP router that provides dynamic routing functionality similar to the "traversal" system from the Pyramid web framework in Python.

For details on the original traversal system see: http://docs.pylonsproject.org/docs/pyramid/en/latest/narr/traversal.html

Simply put, traversal allows you to route HTTP requests by providing a nested map[string]interface{} object called the "root tree". Request URLs are tokenized and recursive lookup is performed on the root tree object.

Example:

If the request URL is /foo/bar/baz/123, it is tokenized to the following:

   ["foo", "bar", "baz", "123"]

Then the equivalent of the following lookup is performed:

   root_tree["foo"]["bar"]["baz"]["123"]

The object that results from this lookup is the "current object". If traversal succeeds, a named handler is then invoked (looked up via the "handler map" provided to the router), otherwise the router returns an appropriate error (404, etc).

For details on how lookup translates to handler names, see the godoc documentation linked above. Travel allows users to emulate traditional traversal mechanics while also providing several ways to modify behavior, such as handler name overrides within the root tree object and limitations on subpath length.

travel's People

Contributors

bkeroack avatar

Stargazers

apo avatar Alex Payne avatar Donal Byrne avatar Florin Broasca avatar Gilles Fabio avatar Shawn Smith avatar Dusan Blagojevic avatar Tommy Bishop avatar Matt Way avatar Dmitry Polushkin avatar Craig Wickesser avatar Amr Tamimi avatar Yung Hwa Kwon avatar Michael Leahy avatar ☮ avatar  avatar

Watchers

James Cloos avatar  avatar

Forkers

marybrown amnonbb

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.