rinzler


Namerinzler JSON
Version 2.2.4 PyPI version JSON
download
home_pagehttps://github.com/feliphebueno/Rinzler
SummaryDjango-based REST API Framework
upload_time2020-07-07 13:22:05
maintainer
docs_urlNone
authorRinzler
requires_python
licenseMIT
keywords rest api framework django
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Rinzler REST Framework

Django-based REST Micro-Framework

# Install requires

```PHP
pip install rinzler
```

# Usage
```Python

# urls.py

import os
import rinzler

from rinzler.core.main_controller import MainController
from your_controller import Controller

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

app = rinzler.boot(BASE_DIR)
assembler = app['url_assembler']

urlpatterns = [
    assembler.mount('hello', Controller),
    assembler.mount('', MainController),
]

```

```Python
# your_controller.py
from collections import OrderedDict

from django.http.request import HttpRequest
from django.views.generic import TemplateView

from rinzler.core.response import Response


class Controller(TemplateView):

    def connect(self, app):

        router = app['router']

        # map end-points to callbacks here
        router.get('/world/', self.hello_world)
        router.get('/{name}/', self.hello_user)

        return app

    # end-point callbacks here:
    @staticmethod
    def hello_world(request: HttpRequest, app: dict(), **params: dict):
        """
        Default route callback
        :param request HttpRequest
        :param app Rinzler's object
        :param params dict url params, if present
        :rtype: Response
        """
        try:
            response = OrderedDict()
            response["status"] = True
            response["data"] = "Hello World!"

            return Response(response, content_type="application/json")
        except BaseException as e:
            response = OrderedDict()
            response["status"] = False
            response["mensagem"] = str(e)

            return Response(response, content_type="application/json", status=500)\

    @staticmethod
    def hello_user(request: HttpRequest, app: dict(), **params: dict):
        """
        Default route callback
        :param request HttpRequest
        :param app Rinzler's object
        :param params dict url params, if present
        :rtype: Response
        """
        try:
            user = params['name']
            response = OrderedDict()
            response["status"] = True
            response["data"] = "Hello {0}!".format(user)

            return Response(response, content_type="application/json")
        except BaseException as e:
            response = OrderedDict()
            response["status"] = False
            response["mensagem"] = str(e)

            return Response(response, content_type="application/json", status=500)

```
### Run django
```shell
python manage.py runserver
August 02, 2017 - 18:48:00
Django version 1.10.4, using settings 'Demo.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
```

### Sample requests

```shell
curl http://localhost:8000/
<center><h1>HTTP/1.1 200 OK RINZLER FRAMEWORK</h1></center>

curl http://localhost:8000/hello/world/
{
  "status": true,
  "data": "Hello World!"
}

curl http://localhost:8000/hello/bob/
{
  "status": true,
  "data": "Hello bob!"
}

curl http://localhost:8000/foo/bar/
{
  "status": false,
  "exceptions": {
    "message": "No route found for GET foo/bar/"
  },
  "request": {
    "content": "",
    "method": "GET",
    "path_info": "foo/bar/"
  },
  "message": "We are sorry, but something went terribly wrong."
}

```



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/feliphebueno/Rinzler",
    "name": "rinzler",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "rest,api,framework,django",
    "author": "Rinzler",
    "author_email": "feliphezion@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/40/4e/1026f7b50ce4424b87777efb29dde83c2a8231abe5cbf2476df1efe8d667/rinzler-2.2.4.tar.gz",
    "platform": "",
    "description": "# Rinzler REST Framework\n\nDjango-based REST Micro-Framework\n\n# Install requires\n\n```PHP\npip install rinzler\n```\n\n# Usage\n```Python\n\n# urls.py\n\nimport os\nimport rinzler\n\nfrom rinzler.core.main_controller import MainController\nfrom your_controller import Controller\n\nBASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))\n\napp = rinzler.boot(BASE_DIR)\nassembler = app['url_assembler']\n\nurlpatterns = [\n    assembler.mount('hello', Controller),\n    assembler.mount('', MainController),\n]\n\n```\n\n```Python\n# your_controller.py\nfrom collections import OrderedDict\n\nfrom django.http.request import HttpRequest\nfrom django.views.generic import TemplateView\n\nfrom rinzler.core.response import Response\n\n\nclass Controller(TemplateView):\n\n    def connect(self, app):\n\n        router = app['router']\n\n        # map end-points to callbacks here\n        router.get('/world/', self.hello_world)\n        router.get('/{name}/', self.hello_user)\n\n        return app\n\n    # end-point callbacks here:\n    @staticmethod\n    def hello_world(request: HttpRequest, app: dict(), **params: dict):\n        \"\"\"\n        Default route callback\n        :param request HttpRequest\n        :param app Rinzler's object\n        :param params dict url params, if present\n        :rtype: Response\n        \"\"\"\n        try:\n            response = OrderedDict()\n            response[\"status\"] = True\n            response[\"data\"] = \"Hello World!\"\n\n            return Response(response, content_type=\"application/json\")\n        except BaseException as e:\n            response = OrderedDict()\n            response[\"status\"] = False\n            response[\"mensagem\"] = str(e)\n\n            return Response(response, content_type=\"application/json\", status=500)\\\n\n    @staticmethod\n    def hello_user(request: HttpRequest, app: dict(), **params: dict):\n        \"\"\"\n        Default route callback\n        :param request HttpRequest\n        :param app Rinzler's object\n        :param params dict url params, if present\n        :rtype: Response\n        \"\"\"\n        try:\n            user = params['name']\n            response = OrderedDict()\n            response[\"status\"] = True\n            response[\"data\"] = \"Hello {0}!\".format(user)\n\n            return Response(response, content_type=\"application/json\")\n        except BaseException as e:\n            response = OrderedDict()\n            response[\"status\"] = False\n            response[\"mensagem\"] = str(e)\n\n            return Response(response, content_type=\"application/json\", status=500)\n\n```\n### Run django\n```shell\npython manage.py runserver\nAugust 02, 2017 - 18:48:00\nDjango version 1.10.4, using settings 'Demo.settings'\nStarting development server at http://127.0.0.1:8000/\nQuit the server with CONTROL-C.\n```\n\n### Sample requests\n\n```shell\ncurl http://localhost:8000/\n<center><h1>HTTP/1.1 200 OK RINZLER FRAMEWORK</h1></center>\n\ncurl http://localhost:8000/hello/world/\n{\n  \"status\": true,\n  \"data\": \"Hello World!\"\n}\n\ncurl http://localhost:8000/hello/bob/\n{\n  \"status\": true,\n  \"data\": \"Hello bob!\"\n}\n\ncurl http://localhost:8000/foo/bar/\n{\n  \"status\": false,\n  \"exceptions\": {\n    \"message\": \"No route found for GET foo/bar/\"\n  },\n  \"request\": {\n    \"content\": \"\",\n    \"method\": \"GET\",\n    \"path_info\": \"foo/bar/\"\n  },\n  \"message\": \"We are sorry, but something went terribly wrong.\"\n}\n\n```\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Django-based REST API Framework",
    "version": "2.2.4",
    "split_keywords": [
        "rest",
        "api",
        "framework",
        "django"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "be2770aa8ec8df71d696ac518de60fb0",
                "sha256": "d2dd7a806096f6aef2ed5543c3f71e80b38bec406a853c864ceed3fffb8efec9"
            },
            "downloads": -1,
            "filename": "rinzler-2.2.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "be2770aa8ec8df71d696ac518de60fb0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 19638,
            "upload_time": "2020-07-07T13:22:02",
            "upload_time_iso_8601": "2020-07-07T13:22:02.073756Z",
            "url": "https://files.pythonhosted.org/packages/11/8d/17ace4971868e18bce416dcc0d10b3cce4ba4edcf1d238fc540b2c243f09/rinzler-2.2.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "0d1779f0b4859b6a56f49ef942fa249a",
                "sha256": "564ca7ec86335ff76186b1b281efec4fcd45a6306ddd306336e345a77dabf545"
            },
            "downloads": -1,
            "filename": "rinzler-2.2.4.tar.gz",
            "has_sig": false,
            "md5_digest": "0d1779f0b4859b6a56f49ef942fa249a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 13465,
            "upload_time": "2020-07-07T13:22:05",
            "upload_time_iso_8601": "2020-07-07T13:22:05.022288Z",
            "url": "https://files.pythonhosted.org/packages/40/4e/1026f7b50ce4424b87777efb29dde83c2a8231abe5cbf2476df1efe8d667/rinzler-2.2.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-07-07 13:22:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": null,
    "github_project": "feliphebueno",
    "error": "Could not fetch GitHub repository",
    "lcname": "rinzler"
}
        
Elapsed time: 0.14495s