A simple api written in Scala using the Spray Framework.
The API includes the following libraries:
- Spray.IO: This is the core of the API that allows users to generate API services. The main components of spray.io are the spray-servlet, spray-routing and all the Akka-related dependencies. Additionally we have added support for caching and json marshalling and unmarshalling using the spray-caching and spray-json dependencies.
- Jetty: This is the application container.
- Typesafe config: The application and the underlying Akka classes use the typesafe config system for configuration.
- Slick: This is a library for database query and access that supports various underlying DBMSs. The user is free to use whatever they want and add the required connector later.
- Testing tools: Scalatest is the preferred testing tool, together with Mockito.
- sbt-assembly: For creating a fat jar with embedded Jetty for distribution.
- sbt-release: For defining custom release steps.
Starting the server is relatively easy. There are two ways of doing this:
- Without building the fat jar.
- Building the fat jar and running it.
To run the application through SBT, run the following command:
sbt container:start shell
It might take some time to compile if you haven't done this yet and then you will see a shell. Then your service will become available and you will be able to query it through the browser.
To stop the server, run:
container:stop
For this operation you will need to create the fat jar first and then simply start it as normal Java application.
To build the fat jar:
sbt assembly
To run the application:
java -jar jar-name.jar
Then to stop the application, just press Ctrl+C.
We have a basic skeleton with almost no functionality that can be used to quickly start developing new APIs.
It is on the following branch: feature/Scala_Api_Skeleton. Just clone it and you are ready to go!
We hope you like the API and find it useful.