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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file routedsl-0.0.1.tar.gz.

File metadata

  • Download URL: routedsl-0.0.1.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0.post20200311 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.8.2

File hashes

Hashes for routedsl-0.0.1.tar.gz
Algorithm Hash digest
SHA256 97bb12f3a561bf9c7ff56e4519f9e9c448c73ba7c7eac705e30532c826c9e648
MD5 d9e2495d47b0a63c7274a907e9e0541d
BLAKE2b-256 d8f95c2da252a660225e1818208b91608c8689abd1bde094d827630ab5551332

See more details on using hashes here.

File details

Details for the file routedsl-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: routedsl-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0.post20200311 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.8.2

File hashes

Hashes for routedsl-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 11496ea5d9303fc205f38e4b757f76d8f48f3c702fc88a8bc913d9613eb5e1f0
MD5 be555784154d11e1f8d1910804282a32
BLAKE2b-256 6aff35b334327ea70f55302cd96b8d2bedf3e07aae39a6bc070a41cc3eba28f4

See more details on using hashes here.

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