Giter Club home page Giter Club logo

akka-http-rest's Introduction

Akka Slick REST service template

Build Status

Goal of example is to show how create reactive REST services on Typesafe stack with Akka and Slick.

Example contains complete REST service for entity interaction.

Features:

  • CRUD operations
  • Entity partial updates
  • CORS support
  • Implemented authentication by token directive
  • Test coverage with ScalaTest
  • Migrations with FlyWay
  • Ready for Docker
  • Testing with inmemory postgres instance that launch automaticly
  • HikaryCP as connection pool

Requirements

Activator

You can get this example through Activator. For more information please use following url that explains how to get this template on your computer step-by-step: https://www.typesafe.com/activator/template/akka-http-rest

Configuration

  • Create database in PostgresSQL
  • Set database settings on application config or set enviroment variables

Changing application config

There are two config files. Application config src/main/resources/application.conf and test config src/test/resources/application.conf.

Enviroment variables

  • PSQL_URL - database url by scheme jdbc:postgresql://host:port/database-name
  • PSQL_USER - database user
  • PSQL_PASSWORD - database password

Run application

To run application, call:

sbt run

If you wanna restart your application without reloading of sbt, use:

sbt re-start

Run in Docker

For launching application in Docker, you must configure database docker instance and run docker image, generated by sbt.

Generating application docker image and publishing on localhost:

sbt docker:publishLocal

Example of running, generated docker image:

docker run --name restapi -e DB_USER=dbuser -e DB_PASSWORD=dbpass -e DB_NAME=dbname -d --link DATABASE_INSTANCE_NAME:database -p 9090:9000 APPLICATION_IMAGE
  • DATABASE_INSTANCE_NAME - name of your Postgresql docker instance
  • APPLICATION_IMAGE - id or name of application docker image

Run tests

To run tests, call:

sbt test

Live example

Application deployed on heroku and can be accessed by URL http://akka-http-rest.herokuapp.com/. First request can take some time, because heroku launch up project.

You can see documentation for this example on Apiary.

Need more explanation?

Great blog article about how it works, thanks @BBartosz!

Copyright

Copyright (C) 2015 Arthur Kushka.

Distributed under the MIT License.

akka-http-rest's People

Contributors

arhelmus avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.