Packages

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 path.

    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

This http object can be found in the following library:

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

,

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.

Linear Supertypes
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
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  6. implicit def directive1Dsl[Keyword, Value, T](implicit continuationDsl: Dsl[Keyword, !![Route, T], Value]): Dsl[Keyword, Directive1[T], Value]
  7. implicit def directiveNDsl[Keyword, Value, L](implicit arg0: Tuple[L], continuationDsl: Dsl[Keyword, !![Route, L], Value]): Dsl[Keyword, Directive[L], Value]
  8. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  9. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  10. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  11. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  12. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  13. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  14. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  15. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  16. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  17. implicit def standardRouteDsl[Keyword, Value](implicit routeDsl: Dsl[Keyword, Route, Value]): Dsl[Keyword, StandardRoute, Value]
  18. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  19. def toString(): String
    Definition Classes
    AnyRef → Any
  20. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  21. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  22. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped