diff options
author | adamw <adam@warski.org> | 2017-06-29 22:16:13 +0200 |
---|---|---|
committer | adamw <adam@warski.org> | 2017-06-29 22:16:13 +0200 |
commit | 56644709f4aeb955dd30dc4a6142370cfe16838c (patch) | |
tree | daf7cc3fc31958e6fd04147953a74c40109a0c6c /core/src/main | |
parent | 1bb7a630a3893978fe8be18fefe22ee25899f3ae (diff) | |
download | sttp-56644709f4aeb955dd30dc4a6142370cfe16838c.tar.gz sttp-56644709f4aeb955dd30dc4a6142370cfe16838c.tar.bz2 sttp-56644709f4aeb955dd30dc4a6142370cfe16838c.zip |
Move model to another package
Diffstat (limited to 'core/src/main')
-rw-r--r-- | core/src/main/scala/com/softwaremill/sttp/model/package.scala | 36 | ||||
-rw-r--r-- | core/src/main/scala/com/softwaremill/sttp/package.scala | 31 |
2 files changed, 38 insertions, 29 deletions
diff --git a/core/src/main/scala/com/softwaremill/sttp/model/package.scala b/core/src/main/scala/com/softwaremill/sttp/model/package.scala new file mode 100644 index 0000000..00f1261 --- /dev/null +++ b/core/src/main/scala/com/softwaremill/sttp/model/package.scala @@ -0,0 +1,36 @@ +package com.softwaremill.sttp + +import java.io.{File, InputStream} +import java.nio.ByteBuffer +import java.nio.file.Path + +package object model { + case class Method(m: String) extends AnyVal + object Method { + val GET = Method("GET") + val HEAD = Method("HEAD") + val POST = Method("POST") + val PUT = Method("PUT") + val DELETE = Method("DELETE") + val OPTIONS = Method("OPTIONS") + val PATCH = Method("PATCH") + } + + sealed trait RequestBody + sealed trait BasicRequestBody extends RequestBody + case object NoBody extends RequestBody + case class StringBody(s: String) extends BasicRequestBody + case class ByteArrayBody(b: Array[Byte]) extends BasicRequestBody + case class ByteBufferBody(b: ByteBuffer) extends BasicRequestBody + case class InputStreamBody(b: InputStream) extends BasicRequestBody + case class InputStreamSupplierBody(b: () => InputStream) extends BasicRequestBody + case class FileBody(f: File) extends BasicRequestBody + case class PathBody(f: Path) extends BasicRequestBody + + sealed trait ResponseAs[T] + object IgnoreResponse extends ResponseAs[Unit] + case class ResponseAsString(encoding: String) extends ResponseAs[String] + object ResponseAsByteArray extends ResponseAs[Array[Byte]] + + case class ResponseAsStream[-S]() +} diff --git a/core/src/main/scala/com/softwaremill/sttp/package.scala b/core/src/main/scala/com/softwaremill/sttp/package.scala index bb9c873..07b4df6 100644 --- a/core/src/main/scala/com/softwaremill/sttp/package.scala +++ b/core/src/main/scala/com/softwaremill/sttp/package.scala @@ -5,6 +5,8 @@ import java.net.URI import java.nio.ByteBuffer import java.nio.file.Path +import com.softwaremill.sttp.model._ + import scala.annotation.implicitNotFound import scala.language.higherKinds @@ -57,40 +59,11 @@ package object sttp { type Id[X] = X type Empty[X] = None.type - case class Method(m: String) extends AnyVal - object Method { - val GET = Method("GET") - val HEAD = Method("HEAD") - val POST = Method("POST") - val PUT = Method("PUT") - val DELETE = Method("DELETE") - val OPTIONS = Method("OPTIONS") - val PATCH = Method("PATCH") - } - - sealed trait ResponseAs[T] - object IgnoreResponse extends ResponseAs[Unit] - case class ResponseAsString(encoding: String) extends ResponseAs[String] - object ResponseAsByteArray extends ResponseAs[Array[Byte]] - - case class ResponseAsStream[-S]() - def ignoreResponse: ResponseAs[Unit] = IgnoreResponse def responseAsString(encoding: String): ResponseAs[String] = ResponseAsString(encoding) def responseAsByteArray: ResponseAs[Array[Byte]] = ResponseAsByteArray def responseAsStream[S]: ResponseAsStream[S] = ResponseAsStream[S]() - sealed trait RequestBody - sealed trait BasicRequestBody extends RequestBody - case object NoBody extends RequestBody - case class StringBody(s: String) extends BasicRequestBody - case class ByteArrayBody(b: Array[Byte]) extends BasicRequestBody - case class ByteBufferBody(b: ByteBuffer) extends BasicRequestBody - case class InputStreamBody(b: InputStream) extends BasicRequestBody - case class InputStreamSupplierBody(b: () => InputStream) extends BasicRequestBody - case class FileBody(f: File) extends BasicRequestBody - case class PathBody(f: Path) extends BasicRequestBody - /** * Use the factory methods `multiPart` to conveniently create instances of this class. A part can be then * further customised using `fileName`, `contentType` and `header` methods. |