Packages

  • package root

    Provided herein is API documentation for Scamper, the HTTP library for Scala.

    Provided herein is API documentation for Scamper, the HTTP library for Scala.

    Definition Classes
    root
  • package scamper

    Defines core types.

    Defines core types.

    HTTP Messages

    At the core of 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 a factory method 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.RequestMethod.Registry.Get
    
    val request = Get("/motd").setHeaders(
      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 a factory method defined in its companion object. Or you can start with a ResponseStatus and use builder methods to further define the response.

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

    Defines standard types for header values.

    Defines standard types for header values.

    import scamper.Implicits.{ stringToEntity, stringToUri }
    import scamper.RequestMethod.Registry.Get
    import scamper.ResponseStatus.Registry.Ok
    import scamper.headers.{ Accept, ContentType, TransferEncoding }
    import scamper.types.{ MediaRange, MediaType, TransferCoding }
    
    val json = MediaRange("application", "json", 0.9f)
    val html = MediaRange("text/html; q=0.1")
    
    val req = Get("/motd")
      .setAccept(json, html)
    
    val text = MediaType("text/plain")
    val gzip = TransferCoding("gzip")
    
    val res = Ok("There is an answer.")
      .setContentType(text)
      .setTransferEncoding(gzip)

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

    import scamper.Implicits.{ stringToEntity, stringToUri }
    import scamper.RequestMethod.Registry.Get
    import scamper.ResponseStatus.Registry.Ok
    import scamper.headers.{ Accept, ContentType, TransferEncoding }
    import scamper.types.Implicits._
    
    val req = Get("/motd")
      .setAccept("application/json; q=0.9", "text/html; q=0.1")
    
    val res = Ok("There is an answer.")
      .setContentType("text/plain")
      .setTransferEncoding("gzip")
    Definition Classes
    scamper
    See also

    scamper.headers

  • ByteContentRange
  • ByteRange
  • CacheDirective
  • CacheDirectives
  • CharsetRange
  • ContentCoding
  • ContentCodingRange
  • ContentRangeType
  • DispositionType
  • EntityTag
  • Implicits
  • KeepAliveParameters
  • LanguageRange
  • LanguageTag
  • LinkType
  • 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[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  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[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 stringToKeepAliveParameters: (String) ⇒ KeepAliveParameters

    Converts string to KeepAliveParameters.

  24. implicit val stringToLanguageRange: (String) ⇒ LanguageRange

    Converts string to LanguageRange.

  25. implicit val stringToLanguageTag: (String) ⇒ LanguageTag

    Converts string to LanguageTag.

  26. implicit val stringToLinkType: (String) ⇒ LinkType

    Converts string to LinkType.

  27. implicit val stringToMediaRange: (String) ⇒ MediaRange

    Converts string to MediaRange.

  28. implicit val stringToMediaType: (String) ⇒ MediaType

    Converts string to MediaType.

  29. implicit val stringToPragmaDirective: (String) ⇒ PragmaDirective

    Converts string to PragmaDirective.

  30. implicit val stringToPreference: (String) ⇒ Preference

    Converts string to Preference.

  31. implicit val stringToProductType: (String) ⇒ ProductType

    Converts string to ProductType.

  32. implicit val stringToProtocol: (String) ⇒ Protocol

    Converts string to Protocol.

  33. implicit val stringToTransferCoding: (String) ⇒ TransferCoding

    Converts string to TransferCoding.

  34. implicit val stringToTransferCodingRange: (String) ⇒ TransferCodingRange

    Converts string to TransferCodingRange.

  35. implicit val stringToViaType: (String) ⇒ ViaType

    Converts string to ViaType.

  36. implicit val stringToWarningType: (String) ⇒ WarningType

    Converts string to WarningType.

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

Inherited from AnyRef

Inherited from Any

Ungrouped