All notable changes to Bocadillo are documented here.
The format of this document is based on Keep a Changelog.
Bocadillo adheres to Semantic Versioning.
- Documentation on the routing algorithm.
- More documentation on how to write views.
- API reference for the
API
class.
- Restructure documentation into 4 clear sections: Getting Started, Topics, How-To and API Reference.
v0.6.0 - 2018-11-26
- Route hooks via
@api.before()
and@api.after()
. - Media types and media handlers:
API([media_type='application/json'])
,api.media_type
,api.media_handlers
. - Support for async callbacks on
RoutingMiddleware
. - Documentation for the above.
- (Development) Black auto-formatting with pre-commit.
- (Development) Documentation guide in
CONTRIBUTING.md
.
- Documentation improvements.
- Exceptions raised inside a middleware callback
(
before_dispatch()
orafter_dispatch()
) are now properly handled by registered error handlers (they were previously left uncaught). - Middleware callbacks (especially
before_dispatch()
) won't be called anymore if the HTTP method is not allowed.
v0.5.0 - 2018-11-18
- Add
boca
, Bocadillo's extensible CLI. - Add
init:custom
command to generate files for building custom Boca commands. - Add VuePress-powered documentation site.
- Moved docs from README.md to docs site.
v0.4.0 - 2018-11-10
- Named routes. Define a named route by passing a
name
to@api.route()
. Get the URL path to a route usingapi.url_for()
or, in templates, theurl_for()
global. - Redirections using
api.redirect()
. Can be by route name, internal URL, or external URL. Make it permanent withpermanent=True
. - Template rendering from string using
api.template_string()
. - Add allowed hosts configuration through
allowed_host
argument toAPI()
. - Experimental support for routing middleware through
bocadillo.RoutingMiddleware
. - Add CORS support with restrictive defaults. Enable using
enable_cors = True
, configure throughcors_config
. - Add HSTS support through
enable_hsts
.
- Updated example app to demonstrate usage of redirects and named routes.
- Responses without content do not send an empty JSON object response anymore. Instead, an empty
text/plain
response is sent. - Responses with 204 status code and no content do not set the
Content-Type
header anymore.
v0.3.1 - 2018-11-09
- Fixed mis-configured
setup.py
preventing Bocadillo from being installed frompip
.
v0.3.0 - 2018-11-09
- Plain text responses using
res.text
. - HTML responses using
res.html
. - Jinja2-powered template rendering through
await api.template()
andapi.template_sync()
. - Mount ASGI or WSGI sub-apps using
app.mount(prefix, sub_app)
. - Static assets using WhiteNoise. Configurable through the
static_root
andstatic_dir
arguments toAPI()
. By default, thestatic
folder is served at/static
. This can be disabled by passingstatic_root = None
toAPI()
. - Register more static files locations by mounting a
bocadillo.static()
sub-app. - Check (at "compile time") that a) a route pattern begins with a forward slash, and b) all parameters of a route are used on its view and vice-versa.
- Use
text/plain
content type if none was set within a view.
- Example app in a dedicated
example/
folder. - Allow overriding a route by reusing a route pattern. Previously, this would have raised an exception.
- Default static root is now
/static
. It previously defaulted to the static directory, which causes issues if the latter was not a relative path. - The
res.content
attribute is now for raw response content, and will not set thetext/plain
content type anymore. Allows to send responses of arbitrary content type. - The default error handler now sends HTML content instead of plain text.
v0.2.1 - 2018-11-04
- Add this
CHANGELOG.md
. - Add error handling.
- Provide a default HTTP error handler, which catches
HTTPError
exceptions during request processing and returns the appropriate HTTP response. - Allow to customize error handling through
@api.error_handler()
andapi.add_error_handler()
. - Allow to restrict HTTP methods supported by a route using the
methods
argument to@api.route()
. Ignored for class-based views: HTTP methods should be restricted by implementing/not implementing the corresponding method on the class.
- Return a
405 Method Not Allowed
response when trying to use a non-implemented method on a class-based view. The previous behavior was to raise an uncaughtValueError
. - Updated
example.py
.
- Fixed a bug that prevented routes without parameters to be handled correctly.
- Prevent registering multiple routes on the same pattern.
- The
API
class, an ASGI-compatible application. Request
andResponse
objects, which are wrappers around Starlette's.- Plain text responses using
res.content
. - JSON responses through
res.media
. - Automatic configuration of the response's
Content-Type
:text/plain
by default,application/json
ifresponse.media
was set orres.content
was left empty. - Route registration through
@api.route()
. - Parametrized routes through f-string expressions, e.g.
{my_param}
. Parameters are passed directly to the view, e.g.my_view(req, resp, my_param)
. Parameters are compliant with the Literal string interpolation specification. In particular, type specifiers are supported (e.g.{age:d}
) which provides basic validation capabilities. - Class-based views. HTTP methods (GET, POST, PUT, PATCH, DELETE) are mapped to the corresponding lowercase methods on the class, e.g.
.get()
. A generic.handle()
method can also be given to process any request (other methods will then be ignored). - Default bind host and port:
127.0.0.1:8000
. - Automatic host and port based on the
PORT
environment variable. IfPORT
is set, a) the app will bind on that port, b) if no host was specified, the app will bind to known hosts (i.e.0.0.0.0
). example.py
app.README.md
.CONTRIBUTING.md
.