Object

com.thoughtworks.dsl.domains.akka

http

Related Doc: package akka

Permalink

object http

This http object provides Dsl type class instances to allow Dsl.Keywords to be used in functions that return akka.http.scaladsl.server.StandardRoute or akka.http.scaladsl.server.Directive, as long as those keywords can be used in functions that return scala.concurrent.Future.

Source
http.scala
Example:
  1. You may want to import type classes in this http object when creating custom Akka HTTP directive.

    import com.thoughtworks.dsl.domains.akka.http._

    Suppose you are creating a directive to asynchronously save the request body to a temporary file and return the file name.

    import java.nio.file.Path
    import java.nio.file.Files
    import com.thoughtworks.dsl.keywords.Await
    import com.thoughtworks.dsl.keywords.Return
    import com.thoughtworks.dsl.keywords.akka.http.TApply
    import akka.stream.scaladsl.FileIO
    import akka.http.scaladsl.server.Directive1
    import akka.http.scaladsl.server.Directives._
    def saveRequestBody: Directive1[Path] = {
      val path = Files.createTempFile(null, null)
      val entity = !TApply(extractRequestEntity)
      val ioResult = !Await(entity.dataBytes.runWith(FileIO.toPath(path)))
      val _ = ioResult.status.get
      !Return(path)
    }

    Then the custom directive can be used in a route.

    def uploadRoute = post {
      val tmpPath = !TApply(saveRequestBody)
      complete(s"${Files.size(tmpPath)} bytes uploaded.")
    }
    Post("/", ('A' to 'Z').toArray) ~> uploadRoute ~> check {
      responseAs[String] should be("26 bytes uploaded.")
    }
Note

You don't need this http object if you only want to use a Dsl.Keywords in a function that returns akka.http.scaladsl.server.Route, because it is a type alias of scala.Function1, which is supported via Dsl#derivedFunction1Dsl.

,

This http object can be found in the following library:

      libraryDependencies += "com.thoughtworks.dsl" %% "domains-akka-http" % "latest.release"

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. http
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. implicit def directive1Dsl[Keyword, Value, T](implicit continuationDsl: Dsl[Keyword, !![Route, T], Value]): Dsl[Keyword, Directive1[T], Value]

    Permalink
  7. implicit def directiveNDsl[Keyword, Value, L](implicit arg0: Tuple[L], continuationDsl: Dsl[Keyword, !![Route, L], Value]): Dsl[Keyword, Directive[L], Value]

    Permalink
  8. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  9. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  10. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  11. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  12. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  13. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  14. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  15. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  16. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  17. implicit def standardRouteDsl[Keyword, Value](implicit routeDsl: Dsl[Keyword, Route, Value]): Dsl[Keyword, StandardRoute, Value]

    Permalink
  18. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  19. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  20. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  21. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  22. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped