Skip to content
Akka HTTP REST API Project Template using Akka HTTP 10.0.4 with Circe 0.7.0 targeting Scala 2.12.x
Branch: master
Clone or download
Latest commit d4c6650 Mar 17, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
project Updated akka-http to 10.0.4, akka-http-json 1.12.0, akka-cors 1.1.11,… Mar 6, 2017
src/main
.gitignore
.travis.yml
LICENSE
README.md
build.sbt Updated akka-http to 10.0.4, akka-http-json 1.12.0, akka-cors 1.1.11,… Mar 6, 2017

README.md

akka-http-circe-json-template

Build Status License

REST API Project Template using Akka HTTP 10.0.4 with Circe 0.7.0 targeting Scala 2.12.x.

This project template proudly uses:

Usage

Start services with sbt:

$ sbt
> run

You can send requests to the following paths:

$ curl http://localhost:8000/api/v1/service1/status
$ curl http://localhost:8000/api/v1/service1/models/<int>
$ curl http://localhost:8000/api/v1/service1/modelsByName/<string>
$ curl -X POST -H 'Content-Type: application/json' http://localhost:8000/api/v2/service1/model -d 
    '{
        "vString": "akka-http-circe",
        "vInt":42, 
        "vLong":100000000,
        "vFloat":2.4,
        "vDouble":4.2,
        "vSeqInt":[1,2,3],
        "vListInt":[4,5,6]
     }'

The routes with logging enabled are under the /v2/ path as below:

$ curl http://localhost:8000/api/v2/service1/status
$ curl http://localhost:8000/api/v2/service1/models/<int>
$ curl http://localhost:8000/api/v2/service1/modelsByName/<string>
$ curl -X POST -H 'Content-Type: application/json' http://localhost:8000/api/v2/service1/model -d 
    '{
        "vString": "akka-http-circe",
        "vInt":42, 
        "vLong":100000000,
        "vFloat":2.4,
        "vDouble":4.2,
        "vSeqInt":[1,2,3],
        "vListInt":[4,5,6]
     }'

You will be able to see in the console the requests reaching the /v2/ as below:

Thread:[akka-http-circe-json-akka.actor.default-dispatcher-16] DEBUG akka.actor.ActorSystemImpl - log-service: Response for
Request : HttpRequest(HttpMethod(POST),http://localhost:8000/api/v2/service1/model,List(Host: localhost:8000, User-Agent: curl/7.51.0, Accept: */*, Timeout-Access: <function1>),
HttpEntity.Strict(application/json,{"vString": "akka-http-circe", "vInt":42, "vLong":100000000, "vFloat":2.4,"vDouble":4.2,"vSeqInt":[1,2,3],"vListInt":[4,5,6]}),HttpProtocol(HTTP/1.1))
Response: Complete(HttpResponse(200 OK,List(),HttpEntity.Strict(application/json,{"message":"model.vString: akka-http-circe - model.vListInt: List(4, 5, 6)"}),HttpProtocol(HTTP/1.1)))

License

This code is open source software licensed under the Apache 2.0 License.

You can’t perform that action at this time.