Skip to content

Instantly share code, notes, and snippets.

@Igosuki
Created May 7, 2019 10:11
Show Gist options
  • Save Igosuki/90eafda9a46090dabeeeb1a944e6431a to your computer and use it in GitHub Desktop.
Save Igosuki/90eafda9a46090dabeeeb1a944e6431a to your computer and use it in GitHub Desktop.
Circe - Magnolia problem example
import io.circe.magnolia.derivation.encoder.auto._
import org.http4s.rho._
import cats.implicits._
import cats.effect._
import com.us.repos._
class AppsEndpoint[F[+ _]: Effect](appsDao: AppsRepo[F], swaggerSyntax: SwaggerSyntax[F]) extends RhoRoutes[F] {
import swaggerSyntax._
// If appsDao.list is F[Seq[App]] then the jsonEncoder outputs '[...]'
// If appsDao.list is F[List[App]] aka colon::colon then the jsonEncoder outputs '{"::": [...]}'
"List apps" ** GET / "apps" |>> {
appsDao.list.flatMap(x => Ok(x))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment