Skip to content

veysiertekin/scala-http-framework-samples

Repository files navigation

HTTP Framework Samples in Scala

Design

All implementations follows below design:





Floe diagram



Rest implementation: ☕️ Coffee Shop API

All examples are using coffee-shop static rest service except ZIO Http because of the some bugs. For ZIO, I have implemented a simple Heroku service described here.

Endpoint Description Return type Request example Return example
/coffee Returns coffee types
Array[String]
http://localhost:9000/coffee
[
"hots",
"iced"
]
/coffee/#category Drinks in the category
Array[
Drink(
title: String,
id: Int,
description: String,
ingredients: List[String]
)
]
http://localhost:9000/coffee/hots
[
{
"title": "Black",
"id": 1,
"description": "Black coffee is as simple as it gets with ground coffee beans steeped in hot water, served warm. And if you want to sound fancy, you can call black coffee by its proper name: cafe noir.",
"ingredients": [
"Coffee"
]
},
...

Akka Http

Http4s

ZIO Http

(as of writing this documentation)

  • Does not support full Http Protocal
  • No native Datadog support yet
  • Client has major pitfalls: stable channel does not have Https support. Beta channel has some bugs (removes trailing / in the URLS etc)
  • Functional, and follows effect library guides
  • Limited documentation (explains just a simple example): https://dream11.github.io/zio-http/docs/index

Finatra

OpenAPI Endpoint

All tapir implementations exposes documentation automatically on API level.

ReadDoc Web UI: http://localhost:9000/docs

Web UI

Additionally, tapir-akka-http also implements a way of exporting openapi yaml. A Github Action uses this implementation and publishes a static swagger documentation at http://veysiertekin.github.io/scala-http-framework-samples

Swagger UI

Simple Remote Service on Heroku

(This Heroku service has been used in ZIO Http)

1- Go to heroku-coffee-shop-service/ in your terminal.

2- Login to Heroku:

heroku login

3- Create a simple app

heroku create
git push heroku main

4- Start application by scaling it to 1

heroku ps:scale web=1

4- You can view http location of the service by:

heroku open

About

Sample REST APIs with various Scala Http Frameworks

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages