Nirum services as WSGI apps
This package provides nirum_wsgi.WsgiApp class which adapts a given Nirum service to a WSGI application:
from yourservice import YourService
from nirum_wsgi import WsgiApp
class YourServiceImpl(YourService):
...
app = WsgiApp(YourServiceImpl())
There’s a development-purpose CLI launcher named nirum-server as well:
nirum-server -H 0.0.0.0 -p 8080 --debug 'yourserviceimpl:YourServiceImpl()'
Changelog
Version 0.3.0
Released on May 25, 2018.
Became ready for the Nirum 0.4.0 compiler. Instances of service classes generated by the compiler older than the version 0.4.0 is supported through LegacyWsgiApp. Note that the constructor of WsgiApp detects which version of compiler is the given service object generated from, and if it’s older than 0.4.0 automatically returns an instance of LegacyWsgiApp instead of WsgiApp, for backward compatibility.
An 400 Bad Request error response for invalid method arguments became to have a more field named errors which contains one or more errors. Its format is like:
{ "message": "There are invalid arguments.", "errors": [ {"path": ".author.name", "message": "Expected a string."}, {"path": ".tags", "message": "Expected an array."} ] }WsgiApp had been an old-style class in Python 2. It’s now a new-style class. No change on Python 3 (since there’s no old-style class in Python 3.)
Added MethodArgumentError to store multiple errors during deserialization of method arguments.
WsgiApp.error() and WsgiApp.make_error_response() methods became able to take extra keyword arguments to extend the result JSON object.
Version 0.2.2
Released on March 20, 2018.
Fixed a runtime TypeError that had been raised when a parameter corresponding to a variable for a query string in @http-resource annotation’s path has an optional type. [#251 by Chang-soo Han]
Version 0.2.1
Released on March 20, 2018.
Fixed a runtime re.error (sre_constants.error) that had been raised when a variable name for a query string has one or more hyphens in @http-resource annotation’s path. [#250 by Chang-soo Han]
Version 0.2.0
Released on February 4, 2018.
Made parameters having an optional type possible to be omitted. [#205]
Added method dispatching by querystring pattern e.g., @http-resource(method="GET", path="/users?from={from}&to={to}"). [#130]
Added basic method dispatching by path pattern (URI template) through http-resource annotation, e.g., @http-resource(method="GET", path="/users/{login}/works/{work-id}/"). [#130]
Added allowed_origins and allowed_headers options for CORS to WsgiApp constructor. It supports simple wildcard (*) pattern syntax as well.
Added AnnotationError, NoJsonError, and ServiceMethodError exceptions.
Since returning a disallowed value which does not match to the return type is the fault the server-side made, the HTTP status code for the case became 500 Internal Server Error instead of 400 Bad Request. Also now it writes logs using logging module.
For the mistakes returning None from a method having non-null return type, now it became to show a more readable and debug-friendly message with a proper response instead of uncaught Python exception.
WsgiApp.url_map attribute was gone.
/ping/ resource was gone.
Fixed nirum-server command able to import a Python module/package from the current working directory (.; CWD).
Version 0.1.0
Released on July 10, 2017.
Metadata
Release files for nirum-wsgi 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nirum-wsgi-0.3.0.tar.gz | 13.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nirum_wsgi-0.3.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 24.2 kB
Release files / nirum-wsgi-0.3.0.tar.gz
| Download URL | nirum-wsgi-0.3.0.tar.gz |
|---|---|
| Size | 13.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0fd1193c907e9e8888e0ac5f03bbfa8f0b80ccd85abfd84ae3a06e1081b16329
|
|
BLAKE2b-256 checksum How to use checksums |
99bfc511db8a55684a522291fb2cb92be21d3acc7f66068e9b290731a1f22ea7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / nirum_wsgi-0.3.0-py2.py3-none-any.whl
| Download URL | nirum_wsgi-0.3.0-py2.py3-none-any.whl |
|---|---|
| Size | 11.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
d8db63ee42edb3f73c18b67c7398532f9afc71ad0a47a4db701b8dd143dea292
|
|
BLAKE2b-256 checksum How to use checksums |
ad194ce1b880531e232224196f659f8a6649b966efdf25b05378f86842bfb3dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |