Skip to content

Async Refinements

Pre-release
Pre-release

Choose a tag to compare

@hlship hlship released this 15 May 17:09

This release refines the async support in Ring considerably; it replaces the odd 'return false' behavior for asynchronous handlers with the more traditional 'return nil' (to close the result channel).

Synchronous handlers are now explicitly invoked in a new thread block; previously they may have been executed inside a go block thread.

There's new middleware for supporting Ring sessions in a fully async pipeline.

All request handler arguments are resolved uniformly via the :arg-resolvers list; this includes previously hard-coded arguments such as request.

The default list of argument resolvers now includes the ability to resolve Ring request headers, for example: An argument named content-type will map to the "content-type" Ring request header.

Request handler function arguments may now be destructured maps; as long as the :as keyword is there (to provide a name for argument resolution). This is useful for extracting a large number of values from the Ring request :params map.

A default argument resolver for params* will resolve to the same as params, but with the map keys Clojurized (underscores replaced with dashes).

A default argument resolver for resource-uri has been added; this is typically used to supply a Location header in a response.

Schema cooercion now understands converting strings to booleans, instants, and UUIDs. Schema validation reporting is better, but still a work in progress. Validation has been simplified; there's no longer any attempt to 'shave' the parameters to match the schema, so you will often need to add a mapping of s/Any to s/Any to prevent spurious failures (from arbitrary query parameters, for example).

Note: there have been a number of refactorings; a few functions have been renamed, and in some places, key/value varargs have been replaced with a simple map.

  • namespace-middleware --> wrap-namespace
  • arg-resolver-middleware -> wrap-with-arg-resolvers

Closed Issues