Git Product home page Git Product logo

escher-akka-http's Introduction

Escher Akka HTTP Build Status Maven Central

Usage

1.0.3 and above

Add the following to build.sbt:

libraryDependencies += "com.emarsys" %% "escher-akka-http" % "1.0.3"

Prior to 1.0.3

Add the following to build.sbt:

resolvers += "Escher repo" at "https://raw.github.com/emartech/escher-akka-http/master/releases"

For versions 0.0.1, 0.0.2 and 0.0.3:

libraryDependencies += "com.emarsys" % "escher-akka-http" % "0.0.3"

For versions above 0.0.4 (note the double %%):

libraryDependencies += "com.emarsys" %% "escher-akka-http" % "0.0.4"

Example

(post & path("customers" / IntNumber / "cart")) { customerId =>
  escherAuthenticate(List("trusted-service")) { body =>
    complete(Cart(customerId, List("product1", "product2")))
  }
}

Testing

Base test trait:

trait ServiceTestBase
  extends WordSpec
    with Matchers
    with ScalatestRouteTest
    with DefaultJsonProtocol
    with FamilyFormats
    with Config
    with ScalaFutures
    with EscherDirectives {

  def signed(r: HttpRequest, intervalMillis: Int = 15): HttpRequest =
    signRequest("trusted-service")(executor, materializer)(r).futureValue(timeout(1.second), interval(intervalMillis.millis))
}

Test:

class CartServiceSpec extends ServiceTestBase with CartService {
  override def testConfigSource = "akka.loglevel = WARNING"

  val customerId = 123

  "POST cart" should {

    trait CreateScope {
      val uri = s"http://${escherConfig.hostName}:${escherConfig.port}/customers/$customerId/cart"
    }

    "return created cart" in new CreateScope {
      val originalId = 101
      signed(Post(uri, Cart(customerId, List("product1", "product2"))), 100) ~> routes ~> check {
        status shouldBe OK
        responseAs[Cart] shouldEqual Cart(customerId, List("product1", "product2"))
      }
    }
  }

}

Creating a release

This library is using sbt-release-early for releasing artifacts. Every push will be released to maven central, see the plugins documentation on the versioning schema.

To cut a final release:

Choose the appropriate version number according to semver then create and push a tag with it, prefixed with v. For example:

$ git tag -a v1.0.3
$ git push --tag

After pushing the tag, while it is not strictly necessary, please draft a release on github with this tag too.

escher-akka-http's People

Contributors

ema-bot avatar miklos-martin avatar suliatis avatar doczir avatar fugafree avatar gyfarkas-test avatar tg44 avatar ksisu avatar jupposessho avatar tt0th avatar andrasp3a avatar dani3lb avatar papgaabor avatar laszlovaspal avatar galatt 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.