Skip to content

A sbt / giter8 template to create Grafter / Http4s projects

Notifications You must be signed in to change notification settings

jcranky/grafter-http4s.g8

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grafter with http4s giter8 template

Generate a http4s project wired with Grafter. Use the following command:

sbt new jcranky/grafter-http4s.g8 -b 0.19

then just enter the values you will be prompted for, cd to the folder generated for your project, and run:

cd [your-project-name]
sbt run

The run command will require you to choose what you want to run: Application or Visualize. The first one runs the http4s server, and the second one generates the application component graph (see Visualize.scala for more information).

You can find more information about Grafter itself here: https://github.com/zalando/grafter

The application generated by this template is very opinionated, but it is just a suggestion on how to use Grafter. The sections below explain the application is organized.

Runnable components

As briefly mentioned above, there are two runnable components: Application and Visualize. Application is the main entry point of the project itself: it loads all the application components and starts the http4s server - as long as everything is ok.

Visualize loads the same application components but, instead of starting a server, it uses Grafter to generate the application components graph using dot notation. See the Visualize.scala file and Grafter's documentation for more details.

ApplicationComponents

This is the root object of the application, where the whole application graph is built from. We use this, as mentioned in the previous section, both to start the application itself and to generate the visualization of the application graph.

HttpServer

Http4s entrypoint in the application, where the Rest endpoints are defined and exposed.

RestApi and the routes package

All rest endpoints are defined in the routes package. A class named RestApi is used to collect all the application's endpoints together, so that they can easily be used from the HttpServer.

services package

Basically a services layer. Nothing special is happening here, but objects in this layer depends on the repository layer.

repository package

Data access layer.

About

A sbt / giter8 template to create Grafter / Http4s projects

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages