restcraft


Namerestcraft JSON
Version 0.0.15 PyPI version JSON
download
home_pageNone
SummaryA minimalist Python WSGI framework for building RESTful APIs.
upload_time2024-04-21 17:25:07
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseMIT
keywords wsgi framework rest api
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # RestCraft WSGI Framework

RestCraft is a lightweight WSGI framework for Python, following the principles of minimalist design. It provides a solid foundation for developing web applications.

## Framework Structure

RestCraft is divided into two main parts:

- **Framework:** Provides the tools, libraries, and base structures needed for web application development. This includes mechanisms for routing requests, handling responses, and a robust middleware system.

- **Project:** The specific application created by the developer using the framework. Here, the developer can define routes, views, middlewares, and any other application-specific logic.

## Main Features

### Settings

- **Configuration File:** Centralizes project settings, allowing the definition of directories for dependencies such as views and middleware folders.

### Middlewares

- **Early Return:** Allows for the early interruption and return of a request before reaching the final handler.
- **Request/Response Modification:** Facilitates the alteration of response and request objects at any stage of the process.
- **Lifecycle Methods:**
  - **before_route:** Executed before a route handler, useful for preprocessing logic.
  - **before_handler:** Executed after route matching and before the handler, ideal for validations and authorizations.
  - **after_handler:** Invoked after the route handler's execution, allowing for modification of the response before it is sent to the client.

### Views

- **Classes:** Uses a class-based system to define views, providing an organized and reusable structure.
- **Defines Routes:** Allows for the explicit definition of routes within view classes.
- **Lifecycle Methods:**
  - **before_handler:** Executed before the handler.
  - **handler:** Route handler where the main logic of the request is processed.
  - **after_handler:** Executed after the handler.
  - **on_exception:** Executed if an exception occurs during the handling of a request.
- **Route Attributes:**
  - **route:** The route pattern.
  - **methods:** List of HTTP methods supported by this view (e.g., GET, POST).

### Routes

- **Dynamic Routing:** RestCraft allows you to specify parts of the URL to be dynamic. These dynamic segments can capture parts of the URL as variables, which can then be passed to your request handlers. For example, defining a route like "/user/\<username\>" can capture any username and pass it to the handler.
- **Wildcard Filters:** You can use wildcard filters in the routes to capture data with specific formats. For instance, you can define a route to only accept integers int or str, uuid and slug. This lets you tailor the handler functions to specific data types or patterns, improving flexibility and reducing the need for validating URLs within your handlers.

### Dependency Injection System

Our custom Dependency Injection (DI) system is designed to manage and inject dependencies dynamically, promoting loose coupling and enhanced modularity within the application. The DI system supports various types of dependency lifetimes, ensuring that components can be instantiated and used according to the specific needs of the application. Below are the types of lifetimes supported:

#### Supported Dependency Lifetimes

- **Singleton**: Singleton dependencies are created once and shared throughout the application's lifetime. Once instantiated, the same instance of a singleton dependency is returned every time it is requested. This is useful for services that maintain a consistent state or provide a shared resource across the application.

- **Transient**: Transient dependencies are recreated every time they are requested. This ensures that a new instance is provided to every consumer, guaranteeing that no shared state is carried over from previous uses. Transient dependencies are ideal for stateless services where each operation is expected to be independent.

- **Scoped**: Scoped dependencies are instantiated once per request, a user session, or a specific task. All requests within the same scope share the same instance, while different scopes will have their own separate instances. This is particularly useful for operations where a common context or state needs to be maintained throughout the operation but should not be shared with other operations.

### Exceptions

- **Easy Custom Exceptions:** Framework supports of custom exceptions, which can be integrated into the application's error handling strategy easily.

### Project Template

[restcraft-template](https://github.com/lsfratel/restcraft-template)

## In Development

It's important to note that RestCraft is under development. Features and functionality may change as the framework evolves.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "restcraft",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "wsgi, framework, rest, api",
    "author": null,
    "author_email": "Lucas Santana <lsfratel@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/1c/b2/16d869373bec8ba08852f27f2cbbf2905e2f81d05a9a85be1bf28b4f82b6/restcraft-0.0.15.tar.gz",
    "platform": null,
    "description": "# RestCraft WSGI Framework\n\nRestCraft is a lightweight WSGI framework for Python, following the principles of minimalist design. It provides a solid foundation for developing web applications.\n\n## Framework Structure\n\nRestCraft is divided into two main parts:\n\n- **Framework:** Provides the tools, libraries, and base structures needed for web application development. This includes mechanisms for routing requests, handling responses, and a robust middleware system.\n\n- **Project:** The specific application created by the developer using the framework. Here, the developer can define routes, views, middlewares, and any other application-specific logic.\n\n## Main Features\n\n### Settings\n\n- **Configuration File:** Centralizes project settings, allowing the definition of directories for dependencies such as views and middleware folders.\n\n### Middlewares\n\n- **Early Return:** Allows for the early interruption and return of a request before reaching the final handler.\n- **Request/Response Modification:** Facilitates the alteration of response and request objects at any stage of the process.\n- **Lifecycle Methods:**\n  - **before_route:** Executed before a route handler, useful for preprocessing logic.\n  - **before_handler:** Executed after route matching and before the handler, ideal for validations and authorizations.\n  - **after_handler:** Invoked after the route handler's execution, allowing for modification of the response before it is sent to the client.\n\n### Views\n\n- **Classes:** Uses a class-based system to define views, providing an organized and reusable structure.\n- **Defines Routes:** Allows for the explicit definition of routes within view classes.\n- **Lifecycle Methods:**\n  - **before_handler:** Executed before the handler.\n  - **handler:** Route handler where the main logic of the request is processed.\n  - **after_handler:** Executed after the handler.\n  - **on_exception:** Executed if an exception occurs during the handling of a request.\n- **Route Attributes:**\n  - **route:** The route pattern.\n  - **methods:** List of HTTP methods supported by this view (e.g., GET, POST).\n\n### Routes\n\n- **Dynamic Routing:** RestCraft allows you to specify parts of the URL to be dynamic. These dynamic segments can capture parts of the URL as variables, which can then be passed to your request handlers. For example, defining a route like \"/user/\\<username\\>\" can capture any username and pass it to the handler.\n- **Wildcard Filters:** You can use wildcard filters in the routes to capture data with specific formats. For instance, you can define a route to only accept integers int or str, uuid and slug. This lets you tailor the handler functions to specific data types or patterns, improving flexibility and reducing the need for validating URLs within your handlers.\n\n### Dependency Injection System\n\nOur custom Dependency Injection (DI) system is designed to manage and inject dependencies dynamically, promoting loose coupling and enhanced modularity within the application. The DI system supports various types of dependency lifetimes, ensuring that components can be instantiated and used according to the specific needs of the application. Below are the types of lifetimes supported:\n\n#### Supported Dependency Lifetimes\n\n- **Singleton**: Singleton dependencies are created once and shared throughout the application's lifetime. Once instantiated, the same instance of a singleton dependency is returned every time it is requested. This is useful for services that maintain a consistent state or provide a shared resource across the application.\n\n- **Transient**: Transient dependencies are recreated every time they are requested. This ensures that a new instance is provided to every consumer, guaranteeing that no shared state is carried over from previous uses. Transient dependencies are ideal for stateless services where each operation is expected to be independent.\n\n- **Scoped**: Scoped dependencies are instantiated once per request, a user session, or a specific task. All requests within the same scope share the same instance, while different scopes will have their own separate instances. This is particularly useful for operations where a common context or state needs to be maintained throughout the operation but should not be shared with other operations.\n\n### Exceptions\n\n- **Easy Custom Exceptions:** Framework supports of custom exceptions, which can be integrated into the application's error handling strategy easily.\n\n### Project Template\n\n[restcraft-template](https://github.com/lsfratel/restcraft-template)\n\n## In Development\n\nIt's important to note that RestCraft is under development. Features and functionality may change as the framework evolves.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A minimalist Python WSGI framework for building RESTful APIs.",
    "version": "0.0.15",
    "project_urls": {
        "Source": "https://github.com/lsfratel/restcraft"
    },
    "split_keywords": [
        "wsgi",
        " framework",
        " rest",
        " api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5127850f8e41729c42243e7e17215c0103b4aca13d88ded9e79dcf05990778bd",
                "md5": "0457371019308e76e7861bc33edf774a",
                "sha256": "0f8203f178a843aad11a3f8c6e3e31957b7f30d5f187564c545469ebcaf520a3"
            },
            "downloads": -1,
            "filename": "restcraft-0.0.15-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0457371019308e76e7861bc33edf774a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 32730,
            "upload_time": "2024-04-21T17:25:05",
            "upload_time_iso_8601": "2024-04-21T17:25:05.682267Z",
            "url": "https://files.pythonhosted.org/packages/51/27/850f8e41729c42243e7e17215c0103b4aca13d88ded9e79dcf05990778bd/restcraft-0.0.15-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1cb216d869373bec8ba08852f27f2cbbf2905e2f81d05a9a85be1bf28b4f82b6",
                "md5": "c7e7560ec7453ffc580033fad1d6c70a",
                "sha256": "6b4d4ce7dbdc04cc01c91e73191c71258156b9086d2ef9154813fd09b7f8e37b"
            },
            "downloads": -1,
            "filename": "restcraft-0.0.15.tar.gz",
            "has_sig": false,
            "md5_digest": "c7e7560ec7453ffc580033fad1d6c70a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 33010,
            "upload_time": "2024-04-21T17:25:07",
            "upload_time_iso_8601": "2024-04-21T17:25:07.727703Z",
            "url": "https://files.pythonhosted.org/packages/1c/b2/16d869373bec8ba08852f27f2cbbf2905e2f81d05a9a85be1bf28b4f82b6/restcraft-0.0.15.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-21 17:25:07",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "lsfratel",
    "github_project": "restcraft",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "restcraft"
}
        
Elapsed time: 0.30463s