Skip to content

Commit

Permalink
Add scaladoc
Browse files Browse the repository at this point in the history
  • Loading branch information
vkostyukov committed Jan 10, 2019
1 parent b93d6e4 commit f70c175
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 7 deletions.
37 changes: 35 additions & 2 deletions core/src/main/scala/io/finch/Endpoint.scala
Original file line number Diff line number Diff line change
Expand Up @@ -889,37 +889,70 @@ object Endpoint {
}

/**
* An [[Endpoint]] that matches chunked requests and lifts their content into a generic
* **binary** stream passed as a type parameter. This method, along with other `bodyStream`
* endpoints, are integration points with streaming libraries such as fs2 and iteratee.
*
* {{{
* scala> import io.finch._, io.finch.iteratee._, cats.effect.IO, io.iteratee.Enumerator
*
* scala> val bin = Endpoint[IO].binaryBodyStream[Enumerator]
* bin: Endpoint[IO, Enumerator[IO, Array[Byte]]] = binaryBodyStream
* }}}
*/
def binaryBodyStream[F[_]: Effect, S[_[_], _]](implicit
LR: LiftReader[S, F]
): Endpoint[F, S[F, Array[Byte]]] = new BinaryBodyStream[F, S]

/**
* An [[Endpoint]] that matches chunked requests and lifts their content into a generic
* **string** stream passed as a type parameter. This method, along with other `bodyStream`
* endpoints, are integration points with streaming libraries such as fs2 and iteratee.
*
* {{{
* scala> import io.finch._, io.finch.iteratee._, cats.effect.IO, io.iteratee.Enumerator
*
* scala> val bin = Endpoint[IO].stringBodyStream[Enumerator]
* bin: Endpoint[IO, Enumerator[IO, String]] = stringBodyStream
* }}}
*/
def stringBodyStream[F[_]: Effect, S[_[_], _]](implicit
LR: LiftReader[S, F]
): Endpoint[F, S[F, String]] = new StringBodyStream[F, S]

/**
* An [[Endpoint]] that matches chunked requests and lifts their content into a generic
* stream passed as a type parameter. This method, along with other `bodyStream`
* endpoints, are integration points with streaming libraries such as fs2 and iteratee.
*
* When, for example, JSON library is import, this endpoint can parse an inbound JSON stream.
*
* {{{
* scala> import io.finch._, io.finch.iteratee._, cats.effect.IO, io.iteratee.Enumerator
*
* scala> import io.finch.circe._, io.circe.generic.auto._
*
* scala> case class Foo(s: String)
* scala> val json = Endpoint[IO].bodyStream[Enumerator, Foo, Application.Json]
* bin: Endpoint[IO, Enumerator[IO, Foo]] = bodyStream
* }}}
*/
def bodyStream[F[_]: Effect, S[_[_], _], A, CT <: String](implicit
LR: LiftReader[S, F],
A: DecodeStream.Aux[S, F, A, CT]
): Endpoint[F, S[F, A]] = new BodyStream[F, S, A, CT]

/**
*
* See [[bodyStream]]. This is just an alias for `bodyStream[?, ?, Application.Json]`.
*/
def jsonBodyStream[F[_]: Effect, S[_[_], _], A](implicit
LR: LiftReader[S, F],
A: DecodeStream.Aux[S, F, A, Application.Json]
) : Endpoint[F, S[F, A]] = bodyStream[F, S, A, Application.Json]

/**
*
* See [[bodyStream]]. This is just an alias for `bodyStream[?, ?, Text.Plain]`.
*/
def textBodyStream[F[_]: Effect, S[_[_], _], A](implicit
LR: LiftReader[S, F],
Expand Down
10 changes: 5 additions & 5 deletions core/src/main/scala/io/finch/EndpointModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -290,23 +290,23 @@ trait EndpointModule[F[_]] {
Endpoint.asyncBody[F]

/**
*
* An alias for [[Endpoint.binaryBodyStream]].
*/
def binaryBodyStream[S[_[_], _]](implicit
F: Effect[F],
LR: LiftReader[S, F]
): Endpoint[F, S[F, Array[Byte]]] = Endpoint.binaryBodyStream[F, S]

/**
*
* An alias for [[Endpoint.stringBodyStream]].
*/
def stringBodyStream[S[_[_], _]](implicit
F: Effect[F],
LR: LiftReader[S, F]
): Endpoint[F, S[F, String]] = Endpoint.stringBodyStream[F, S]

/**
*
* An alias for [[Endpoint.bodyStream]].
*/
def bodyStream[S[_[_], _], A, CT <: String](implicit
F: Effect[F],
Expand All @@ -315,7 +315,7 @@ trait EndpointModule[F[_]] {
): Endpoint[F, S[F, A]] = Endpoint.bodyStream[F, S, A, CT]

/**
*
* An alias for [[Endpoint.jsonBodyStream]].
*/
def jsonBodyStream[S[_[_], _], A](implicit
F: Effect[F],
Expand All @@ -324,7 +324,7 @@ trait EndpointModule[F[_]] {
): Endpoint[F, S[F, A]] = Endpoint.jsonBodyStream[F, S, A]

/**
*
* An alias for [[Endpoint.textBodyStream]].
*/
def textBodyStream[S[_[_], _], A](implicit
F: Effect[F],
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/scala/io/finch/endpoint/body.scala
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,6 @@ private[finch] final class BodyStream[F[_], S[_[_], _], A, CT <: String](implici

protected def prepare(r: Reader[Buf], cs: Charset): Output[S[F, A]] =
Output.payload(A(LR(r), cs))

override def toString: String = "bodyStream"
}

0 comments on commit f70c175

Please sign in to comment.