ironfish / acmeco-user

Akka HTTP REST example

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Acmeco User Akka HTTP server

This is a sample Akka HTTP endpoint keeping an in-memory database of users that can be created and listed.

Sources in the sample:

  • QuickstartApp.scala -- contains the main method which bootstraps the application
  • UserRoutes.scala -- Akka HTTP routes defining exposed endpoints
  • UserRegistry.scala -- the actor which handles the registration requests
  • JsonFormats.scala -- converts the JSON data from requests into Scala types and from Scala types into JSON responses

Interacting with the sample

After starting the sample with sbt run the following requests can be made:

List all users:

curl http://localhost:8080/users

Create a user:

curl -XPOST http://localhost:8080/users -d '{"name": "Liselott", "age": 32, "countryOfResidence": "Norway"}' -H "Content-Type:application/json"

Get the details of one user:

curl http://localhost:8080/users/Liselott

Delete a user:

curl -XDELETE http://localhost:8080/users/Liselott

About

Akka HTTP REST example

License:Apache License 2.0


Languages

Language:Scala 100.0%