Skip to content

An example http4s project with tests and error handling

Notifications You must be signed in to change notification settings

marcintustin/http4s-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HTTP4S example project

This project demonstrates a minimal HTTP4S project (generated from the g8 template; such business logic as exists is jammed into the service layer).

The purpose of this project is to demonstrating testing HTTP4S projects, handling errors, and custom JSON decoding

This project uses http4s 0.15

Structure

Server.scala is purely stock from g8 template.

src/main/scala/com/example/apipractice/HelloWorld.scala contains the interesting error handling and JSON decoding logic. In a real application, I would strongly recommend separating out the business logic.

src/test/scala/com/example/apipractice/HelloWorldTest.scala demonstrates invoking the service with a hand-built request, and extracting the response body. The example uses scalatest, but does not rely on any special scalatest features.

About

An example http4s project with tests and error handling

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages