帮酷LOGO

Example of reactive REST service written on akka-http with slick

在 akka http上使用灵活REST服务编写示例

将光标移到/点击文章中的句子上,可以查看译文。 显示原文      显示译文      双语对照

  • 显示内容
文章标签:AKKA  Slick  sli  REST  服务  HTTP  akka-http  react  
Example of reactive REST service written on akka-http with slick



  • Source Code:akka-http-rest
  • WebSite:http://www.github.com/ArchDev/akka-http-rest
  • akka-http-rest Documents
  • akka-http-rest Download
  • Akka Slick REST service template

    Build Status

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

    Example contains complete REST service for entity interaction.

    Features :

    • CRUD operations
    • Entity partial updates
    • CORS support
    • Authentication with JWT tokens
    • Test coverage with ScalaTest
    • Migrations with FlyWay
    • Ready for Docker
    • Testing with in-memory postgres instance that launch automatically
    • HikaryCP as connection pool

    Requirements

    Development guide

    This application is fully tested with Unit and it tests.you don't need to launch server locally for development.my recommendation is to write a test before changes and work via TDD.to ensure that application working properly, you should run it :sbt test.

    Structure

    All business logic is located in core package, every package inside is related to some domain.Service classes contains high level logic that related to data manipulation, that means that service must not implement storaging and querying for the data.for storaging there are Storage classes that always have interface with two implementation, production one and in-memory one.that's needed to fasten tests of services and make it independent from each other.

    Checking code coverage

    To generate code coverage report, please run :sbt clean coverage test coverageReport. then you will have HTML pages with reports in/target/scala-2.12/scoverage-report

    Packaging

    Application packaging implemented via sbt-native-packager plugin.currently in build.sbt enabled two types :docker and universal.

    Universal packager
    To package application as a universal app, use :sbt universal:packageBin. Application zip archive will be generated in /target/universal/ folder.

    Docker packager
    To package application as docker image, use sbt docker:publishLocal.it will generate and push application image into your local docker store.for information about publishing to external store, please, read plugin documentation.

    Running

    If you want to launch application locally (its not recommended) you need to start Postgres instance locally and fulfill some env variables :

    • JDBC_URL - url to your database
    • JDBC_USER - database username
    • JDBC_PASSWORD - database password

    After that, just run sbt run and enjoy hacking.for better expirience you can use sbt reStart that will give you ability to restart application without restarting of sbt.

    Deployment on production

    Easiest way to deliver your application, is to do it with docker.Publish image into the store and then use docker-compose file with structure like in docker-compose.yml.

    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.

    Copyright

    Copyright (C) 2017 Arthur Kushka.
    Distributed under the MIT License.



    文章标签:服务  HTTP  react  REST  sli  AKKA  Slick  akka-http  

    Copyright © 2011 HelpLib All rights reserved.    知识分享协议 京ICP备05059198号-3  |  如果智培  |  酷兔英语