Skip to content

Repository files navigation

http4s-fabric

CI Maven Central

Provides EntityEncoder and EntityDecoder support using the Fabric JSON library.

Cross-built for Scala 2.13 and 3.

SBT Setup

libraryDependencies += "org.http4s" %% "http4s-fabric" % "1.0.0-M48"

The milestone number tracks the http4s-core release this version is built against.

Usage

A single import supplies an EntityDecoder and EntityEncoder for any type with a Fabric RW instance — see Convert:

import org.http4s.fabric._

case class Person(name: String, age: Int)

object Person {
  implicit val rw: RW[Person] = RW.gen[Person]
}

// Person now encodes to and decodes from application/json

Note that the derived instances are specialized to cats.effect.IO.

Filters

Import the package object for the default behavior, or instantiate FabricEntitySupport directly with Fabric filters to transform JSON on the way in and out — for example, to exchange snake_case JSON with camelCase Scala fields:

import fabric.filter._
import org.http4s.fabric.FabricEntitySupport

object SnakeCaseSupport
    extends FabricEntitySupport(SnakeToCamelFilter, CamelToSnakeFilter)

import SnakeCaseSupport._

About

Fabric integration module for http4s

Resources

Code of conduct

Contributing

Security policy

Stars

4 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages