Skip to content

kevin-lee/http4s-example-app

Repository files navigation

http4s-example-app

Build Status Build Status Build Status

How to Run

sbt run

Once you get log messages like this

[info] running io.kevinlee.http4sexampleapp.MainServer
[ioapp-compute-0] INFO  o.h.b.c.n.NIO1SocketServerGroup - Service bound to address /0:0:0:0:0:0:0:0:8080
[ioapp-compute-0] INFO  o.h.b.s.BlazeServerBuilder -
  _   _   _        _ _
 | |_| |_| |_ _ __| | | ___
 | ' \  _|  _| '_ \_  _(_-<
 |_||_\__|\__| .__/ |_|/__/
             |_|
[ioapp-compute-0] INFO  o.h.b.s.BlazeServerBuilder - http4s v0.22.8 on blaze v0.15.2 started at http://[::]:8080/

In development, reStart and reStop are recommended to start and stop the app.

  1. Access http://localhost:8080/hello in your web browser. It will give the following JSON.

    {
      "message": "Hello, World"
    }
  2. Access http://localhost:8080/hello/YOUR_NAME in your web browser. It will give the following JSON.

    {
      "message": "Hello, YOUR_NAME"
    }
  3. Access http://localhost:8080/hello/add with two numbers in the path. e.g.) http://localhost:8080/hello/add/2/5

    Result:

    {
      "result": 7
    }
  4. Access http://localhost:8080/html/index.html to access an example static html page. It's handled by StaticHtmlService.