Packages

  • package root
    Definition Classes
    root
  • package scamper

    At the core Scamper is HttpMessage, which is a trait that defines the fundamental characteristics of an HTTP message.

    HTTP Messages

    At the core Scamper is HttpMessage, which is a trait that defines the fundamental characteristics of an HTTP message. HttpRequest and HttpResponse extend the specification to define characteristics specific to their respective message types.

    An HttpRequest is created using one of the factory methods defined in its companion object. Or you can start with a RequestMethod and use builder methods to further define the request.

    import scamper.Header
    import scamper.Implicits.stringToUri
    import scamper.RequestMethods.GET
    
    val request = GET("/motd").withHeaders(
      Header("Host", "localhost:8080"),
      Header("Accept", "text/plain")
    )
    
    printf("Request Method: %s%n", request.method)
    printf("Target URI: %s%n", request.target)
    
    request.headers.foreach(println)
    
    val host: Option[String] = request.getHeaderValue("Host")

    An HttpResponse is created using one of the factory methods defined in its companion object. Or you can start with a ResponseStatus and use builder methods to further define the response.

    import scamper.{ BodyParsers, Header }
    import scamper.Implicits.stringToEntity
    import scamper.ResponseStatuses.Ok
    
    val response = Ok("There is an answer.").withHeaders(
      Header("Content-Type", "text/plain"),
      Header("Connection", "close")
    )
    
    printf("Status Code: %s%n", response.status.code)
    printf("Reason Phrase: %s%n", response.status.reason)
    
    response.headers.foreach(println)
    
    val contentType: Option[String] = response.getHeaderValue("Content-Type")
    
    implicit val parser = BodyParsers.text()
    
    printf("Body: %s%n", response.as[String])
    Definition Classes
    root
  • package types

    Defines standardized types for header classes in scamper.headers.

    Defines standardized types for header classes in scamper.headers.

    import scamper.Implicits.{ stringToEntity, stringToUri }
    import scamper.RequestMethods.GET
    import scamper.ResponseStatuses.Ok
    import scamper.headers.{ Accept, ContentType, TransferEncoding }
    import scamper.types.{ MediaRange, MediaType, TransferCoding }
    
    val json = MediaRange("application", "json", 0.9f)
    val html = MediaRange.parse("text/html; q=0.1")
    
    val req = GET("/motd").withAccept(json, html)
    
    val text = MediaType.parse("text/plain")
    val gzip = TransferCoding("gzip")
    
    val res = Ok("There is an answer.").withContentType(text).withTransferEncoding(gzip)

    Using values defined in Implicits, properly formatted strings can be implicitly converted to standardized types.

    import scamper.Implicits.{ stringToEntity, stringToUri }
    import scamper.RequestMethods.GET
    import scamper.ResponseStatuses.Ok
    import scamper.headers.{ Accept, ContentType, TransferEncoding }
    import scamper.types.Implicits._
    
    val req = GET("/motd").withAccept("application/json; q=0.9", "text/html; q=0.1")
    
    val res = Ok("There is an answer.").withContentType("text/plain").withTransferEncoding("gzip")
    Definition Classes
    scamper
  • ByteContentRange
  • ByteRange
  • CacheDirective
  • CacheDirectives
  • CharsetRange
  • ContentCoding
  • ContentCodingRange
  • ContentRangeType
  • DispositionType
  • EntityTag
  • Implicits
  • LanguageRange
  • LanguageTag
  • LinkValue
  • MediaRange
  • MediaType
  • PragmaDirective
  • PragmaDirectives
  • Preference
  • Preferences
  • ProductType
  • Protocol
  • RangeType
  • TransferCoding
  • TransferCodingRange
  • ViaType
  • WarningType
o

scamper.types

Implicits

object Implicits

Contains implicit converter functions.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Implicits
  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. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  10. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  11. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  12. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  13. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  14. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  15. implicit val stringToByteContentRange: (String) ⇒ ByteContentRange

    Converts string to ByteContentRange.

  16. implicit val stringToByteRange: (String) ⇒ ByteRange

    Converts string to ByteRange.

  17. implicit val stringToCacheDirective: (String) ⇒ CacheDirective

    Converts string to CacheDirective.

  18. implicit val stringToCharsetRange: (String) ⇒ CharsetRange

    Converts string to CharsetRange.

  19. implicit val stringToContentCoding: (String) ⇒ ContentCoding

    Converts string to ContentCoding.

  20. implicit val stringToContentCodingRange: (String) ⇒ ContentCodingRange

    Converts string to ContentCodingRange.

  21. implicit val stringToDispositionType: (String) ⇒ DispositionType

    Converts string to DispositionType.

  22. implicit val stringToEntityTag: (String) ⇒ EntityTag

    Converts string to EntityTag.

  23. implicit val stringToLanguageRange: (String) ⇒ LanguageRange

    Converts string to LanguageRange.

  24. implicit val stringToLanguageTag: (String) ⇒ LanguageTag

    Converts string to LanguageTag.

  25. implicit val stringToLinkValue: (String) ⇒ LinkValue

    Converts string to LinkValue.

  26. implicit val stringToMediaRange: (String) ⇒ MediaRange

    Converts string to MediaRange.

  27. implicit val stringToMediaType: (String) ⇒ MediaType

    Converts string to MediaType.

  28. implicit val stringToPragmaDirective: (String) ⇒ PragmaDirective

    Converts string to PragmaDirective.

  29. implicit val stringToPreference: (String) ⇒ Preference

    Converts string to Preference.

  30. implicit val stringToProductType: (String) ⇒ ProductType

    Converts string to ProductType.

  31. implicit val stringToProtocol: (String) ⇒ Protocol

    Converts string to Protocol.

  32. implicit val stringToTransferCoding: (String) ⇒ TransferCoding

    Converts string to TransferCoding.

  33. implicit val stringToTransferCodingRange: (String) ⇒ TransferCodingRange

    Converts string to TransferCodingRange.

  34. implicit val stringToViaType: (String) ⇒ ViaType

    Converts string to ViaType.

  35. implicit val stringToWarningType: (String) ⇒ WarningType

    Converts string to WarningType.

  36. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  37. def toString(): String
    Definition Classes
    AnyRef → Any
  38. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  39. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  40. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped