Skip to main content

Route DSL

Project description

https://travis-ci.org/avanov/routedsl.svg?branch=develop https://circleci.com/gh/avanov/routedsl/tree/develop.svg?style=svg https://coveralls.io/repos/github/avanov/routedsl/badge.svg?branch=develop Requirements Status Documentation Status Latest PyPI Release

Python eDSL for your Web Routes

pip install routedsl

Compose everything in one place

routes = Routes() (
    GET / 'users' / ('user_id', User, "User identifier")
        | HEADERS | Headers
        | RETURNS | JSON [ User ]
        | HANDLER | get_user_info
        | GUARDS  | ( Headers.content_type | IS | 'application/json'
                    )
        | DOCS    | """Get a user profile in JSON format"""
)(
    POST / 'users' / ('user_id', User)
        | HEADERS | Headers
        | PAYLOAD | JSON [ User ]
        | RETURNS | OK [ JSON [ bool ] ]
        | HANDLER | update_user_info
)

or define pieces separately, then assemble your routing map:

DefaultHeaders = HEADERS | Headers
DefaultHandler = HANDLER | default_handler

DefaultEndpoint = GET / DefaultHeaders
                      | DefaultHandler

routes = Routes() | DefaultEndpoint

Use nesting under common prefix

routes = (routes / 'users' / ('user_id', User)) (
    POST / 'edit'
        | HEADERS | Headers
        | RETURNS | JSON [ User ]
        | HANDLER | update_user_info
)

Read more in Official Documentation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

routedsl-0.0.1.tar.gz (5.2 kB view hashes)

Uploaded Source

Built Distribution

routedsl-0.0.1-py3-none-any.whl (6.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page