sttp.model

package sttp.model

Most model classes contain both serialisation & parsing functionality, following these conventions:

  • .toString returns a representation of the model class in a format as in an HTTP request/response. For example, for an uri this will be http://..., for a header [name]: [value], etc.
  • [SthCompanionObject].parse(serialized: String): Either[String, Sth]: returns an error message or an instance of the model class
  • [SthCompanionObject].unsafeParse(serialized: String): Sth: returns an instance of the model class or in case of an error, throws an exception.
  • [SthCompanionObject].unsafeApply(values): creates an instance of the model class; validates the input values and in case of an error, throws an exception. An error could be e.g. that the input values contain characters outside of the allowed range
  • [SthCompanionObject].safeApply(...): Either[String, Sth]: same as above, but doesn't throw exceptions. Instead, returns an error message or the model class instance
  • [SthCompanionObject].apply(...): Sth: creates the model type, without validation, and without throwing exceptions

Attributes

Members list

Packages

package sttp.model.sse

Type members

Classlikes

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
case class ContentTypeRange(mainType: String, subType: String, charset: String, otherParameters: Map[String, String])

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
trait Encodings

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Encodings
object Encodings extends Encodings

Attributes

Companion
trait
Supertypes
trait Encodings
class Object
trait Matchable
class Any
Self type
Encodings.type
trait HasHeaders

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Headers
class Part[T]
class Header(val name: String, val value: String)

An HTTP header. The name property is case-insensitive during equality checks.

An HTTP header. The name property is case-insensitive during equality checks.

To compare if two headers have the same name, use the is method, which does a case-insensitive check, instead of comparing the name property.

The name and value should be already encoded (if necessary), as when serialised, they end up unmodified in the header.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
object Header

For a description of the behavior of apply, safeApply and unsafeApply methods, see sttp.model.

For a description of the behavior of apply, safeApply and unsafeApply methods, see sttp.model.

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
Header.type
trait HeaderNames

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object HeaderNames
object HeaderNames extends HeaderNames

Attributes

Companion
trait
Supertypes
trait HeaderNames
class Object
trait Matchable
class Any
Self type
case class Headers(headers: Seq[Header]) extends HasHeaders

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait HasHeaders
class Object
trait Matchable
class Any
Show all
object Headers

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Headers.type
sealed trait HttpVersion

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object HTTP_1
object HTTP_1_1
object HTTP_2
object HTTP_3
object HttpVersion

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
case class MediaType(mainType: String, subType: String, charset: Option[String], otherParameters: Map[String, String])

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object MediaType extends MediaTypes

For a description of the behavior of apply, parse, safeApply and unsafeApply methods, see sttp.model.

For a description of the behavior of apply, parse, safeApply and unsafeApply methods, see sttp.model.

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
trait MediaTypes
class Object
trait Matchable
class Any
Show all
Self type
MediaType.type
trait MediaTypes

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
object MediaType
final case class Method(method: String) extends AnyVal

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class AnyVal
trait Matchable
class Any
Show all
object Method extends Methods

For a description of the behavior of apply, safeApply and unsafeApply methods, see sttp.model.

For a description of the behavior of apply, safeApply and unsafeApply methods, see sttp.model.

Attributes

Companion
class
Supertypes
trait Methods
class Object
trait Matchable
class Any
Self type
Method.type
trait Methods

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Method
case class Part[+T](name: String, body: T, otherDispositionParams: Map[String, String], headers: Seq[Header]) extends HasHeaders

A decoded representation of a multipart part.

A decoded representation of a multipart part.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait HasHeaders
class Object
trait Matchable
class Any
Show all
object Part

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Part.type
case class QueryParams(ps: Seq[(String, Seq[String])])

Represents query parameters, where each parameter can have 0, 1, or more values. All query parameters are assumed to be decoded.

Represents query parameters, where each parameter can have 0, 1, or more values. All query parameters are assumed to be decoded.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object QueryParams

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
trait RequestMetadata extends HasHeaders

Attributes

Companion
object
Supertypes
trait HasHeaders
class Object
trait Matchable
class Any

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Companion
object
Supertypes
trait HasHeaders
class Object
trait Matchable
class Any

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
final class StatusCode(val code: Int) extends AnyVal

Attributes

Companion
object
Supertypes
class AnyVal
trait Matchable
class Any
object StatusCode extends StatusCodes

For a description of the behavior of apply, safeApply and unsafeApply methods, see sttp.model.

For a description of the behavior of apply, safeApply and unsafeApply methods, see sttp.model.

Attributes

Companion
class
Supertypes
trait StatusCodes
class Object
trait Matchable
class Any
Self type
StatusCode.type
trait StatusCodes

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
object StatusCode
case class StatusText(text: String)

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object StatusText

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
StatusText.type
case class Uri(scheme: Option[String], authority: Option[Authority], pathSegments: PathSegments, querySegments: Seq[QuerySegment], fragmentSegment: Option[Segment])

A URI. Can represent both relative and absolute URIs, hence in terms of https://tools.ietf.org/html/rfc3986, this is a URI reference.

A URI. Can represent both relative and absolute URIs, hence in terms of https://tools.ietf.org/html/rfc3986, this is a URI reference.

All components (scheme, host, query, ...) are stored decoded, and become encoded upon serialization (using toString).

Instances can be created using the uri interpolator: uri"..." (see UriInterpolator), or the factory methods on the Uri companion object.

The apply/safeApply/unsafeApply methods create absolute URIs and require a host. The relative methods creates a relative URI, given path/query/fragment components.

Value parameters

querySegments

Either key-value pairs, single values, or plain query segments. Key value pairs will be serialized as k=v, and blocks of key-value pairs/single values will be combined using &. Note that no & or other separators are added around plain query segments - if required, they need to be added manually as part of the plain query segment. Custom encoding logic can be provided when creating a segment.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Uri extends UriInterpolator

For a general description of the behavior of apply, parse, safeApply and unsafeApply methods, see sttp.model.

For a general description of the behavior of apply, parse, safeApply and unsafeApply methods, see sttp.model.

The safeApply methods return a validation error if the scheme contains illegal characters or if the host is empty.

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Show all
Self type
Uri.type

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Uri

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type