Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

roughrider.routing

Routing capabilities for horseman nodes.

This package introduces a ‘Routes’ component that allows registration of endpoints on one or several HTTP Methods. Routes can be looked up by URL or by name.

Example

Below is an example of a barebone API, handling a GET request on ‘/’ and returning a JSON response.

import logging
from bjoern import run
from horseman.meta import SentryNode, Overhead, APIView
from horseman.response import Response
from roughrider.routing import Routes


class Request(Overhead):

    data = None

    def __init__(self, environ):
        self.environ = environ

    def extract(self):
        self.data = 'somedata'


class RootNode(SentryNode):

    def __init__(self):
        self.routes = Routes()

    def resolve(self, path: str, environ: dict):
        route = self.routes.match_method(path, environ['REQUEST_METHOD'])
        if route is not None:
            request = Request(environ)
            return route.endpoint(request, **route.params)

    def handle_exception(self, exc_info, environ):
        logging.error(exc_info)


app = RootNode()

@app.routes.register('/')
class View(APIView):

    def GET(self, overhead):
        return Response.to_json(200, {"Result": "OK"})

run(
    host="0.0.0.0",
    port=8080,
    reuse_port=True,
    wsgi_app=app,
)

CHANGES

0.2.1 (2022-03-15)

  • Fixed bug existing while registering 2 routes with the same name.

0.2 (2021-10-09)

  • Code structure was reshuffled for more readability.

0.1 (2021-10-08)

  • Initial release

Metadata

Release files for roughrider.routing 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for roughrider.routing 0.2.1
File Size Uploaded Provenance Actions
roughrider.routing-0.2.1.tar.gz 1.1 MB Without provenance Details for roughrider.routing-0.2.1.tar.gz

Release files / roughrider.routing-0.2.1.tar.gz

Download URL roughrider.routing-0.2.1.tar.gz
Size 1.1 MB
Tags Source
SHA-256 checksum
How to use checksums
b8585518a40691e5ec03fd6745dbde66aec6c0d50296e73e5bc40858f7a8f5aa
BLAKE2b-256 checksum
How to use checksums
2f33fbbb9b0644a07563ba40c98f2e479169fdcabb34c53200d162cde2ce99bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10

Security for roughrider.routing 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page