Fintrospect is a Scala web-framework with an intelligent HTTP routing layer, based on the Finagle RPC framework from Twitter. Via a shared contract, it provides a simple way to implement fast webservice endpoints and HTTP clients which are:

Template View support (with Hot-Reloading) for building responses with Mustache or Handlebars

Anonymising headers for dynamic-path based endpoints, removing all dynamic path elements. This allows, for example, calls to particular endpoints to be grouped for metric purposes. e.g. /search/author/rowling becomes /search/author/{name}

Interacts seamlessly with other Finagle based libraries, such as Finagle OAuth2

Utilities to help you unit-test endpoint services and write HTTP contract tests for remote dependencies

Get it

Fintrospect is intentionally dependency-lite by design - other than Finagle, the core library itself only has a single non org.scala dependency. No dependency on Scalaz, Cats or Shapeless, so there are no compatibility headaches.

To activate the extension library features (JSON, templates etc), additional dependencies are required - please see here for details.

Add the following lines to build.sbt - the lib is hosted in Maven Central and JCenter:

See the code

Learn it

Server-side contracts

Adding Fintrospect routes to a Finagle HTTP server is simple. For this example, we'll imagine a Library application (see the example above for the full code) which will be rendering Swagger v2 documentation.

Define the endpoint

This example is quite contrived (and almost all the code is optional) but shows the kind of thing that can be done. Note the use of the example response object, which will be broken down to provide the JSON model for the Swagger documentation.

View the generated documentation

The auto-generated documentation lives at the root of the module, so point the Swagger UI at http://{host}:8080/library to see it.

Client-side contracts

Declare the fields to be sent to the client service and then bind them to a remote service. This produces a simple function, which can then be called with the bindings for each parameter.

Since we can re-use the routes between client and server, we can easily create fake implementations of remote systems without having to redefine the contract. This means that marshalling of objects and values into/out of the HTTP messages can be reused.