Packages

package mason

Manage your REST resources with Mason.

More about HATEOAS : https://en.wikipedia.org/wiki/HATEOAS

Mason specs can be found here : https://github.com/JornWildt/Mason/blob/master/Documentation/Mason-draft-2.md

This library uses play-json : https://github.com/playframework/play-json

As for play-json, write an implicit schidaine.mason.MasonWrite in a companion object of your resource.

Example :

import play.api.libs.json._
import schidaine.mason._

case class MyObject(data: String)
object MyObject extends MasonValues {
  implicit val masonWrite = new MasonWrite[MyObject] {
    def writes(o: MyObject) =
      Namespaces("ns1" -> "https://localhost/rels") ++
      Json.obj("object" -> o.data) ++
      Controls(
        "self" -> Link($.href := "https://localhost/my-object"),
        "ns1:add-description" -> Link($.href := "https://localhost/my-object/descriptions", $.encoding := JSON)
      )
  }
}

Use schidaine.mason.Mason object to manipulate a such resource.

Example :

val o = MyObject("Tardis")
Mason.toJson(o)

See schidaine.mason.MasonKeyBuilder to see available properties (Mason specs are not yet fully implemented).

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. mason
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. case class Controls(refs: (String, Link)*) extends MasonObject with Product with Serializable

    Represents a @controls object as a collection of references.

    Represents a @controls object as a collection of references.

    Example:

    val ctrl = Controls("self" -> Link($.href := "http://my.domain.io/my-resource"))
  2. trait Encodings extends AnyRef

    Standard Encodings

  3. case class Error(message: Message, properties: OptionalErrorProperty*) extends MasonObject with Product with Serializable

    Represents a @error object, only present in the root object

    Represents a @error object, only present in the root object

    message

    a mandatory errorMessage

    properties

    optional properties ; in case of duplicated property names, the last one override the others.

  4. sealed trait ErrorProperty extends Property

    Properties available in @error object

  5. case class GenericProperty(name: String, value: JsValue) extends MetaProperty with OptionalErrorProperty with Product with Serializable

    A generic property allowing extension of @meta and @error objects

  6. class GenericPropertyBuilder extends AnyRef

    Factory for GenericProperty

  7. trait HttpVerbs extends AnyRef

    Standard HTTP Verbs

  8. case class JsonObject(value: JsObject) extends MasonObject with Product with Serializable

    Any JsObject as a MasonObject

  9. case class Link(href: Href, properties: OptionalLinkProperty*) extends Product with Serializable

    Represents a link object

    Represents a link object

    Example :

    val link = Link($.href := "http://my.domain.io/my-resource", $.method := POST)
    href

    a mandatory href property

    properties

    optional link properties ; in case of duplicated property names, the last one override the others.

  10. sealed trait LinkProperty extends Property

    Properties available in a link description

  11. trait MasonKeyBuilder extends AnyRef

    DSL for Mason

    DSL for Mason

    Meta(
      $.metaTitle := "title",
      $.metaDescription := "a bigger description",
      $.property("extended") := "an extended field"
      $.relation("copyright") := Link(
        $.href := "/copyright"
        $.title := "Link to copyright information")
    )
  12. sealed trait MasonObject extends AnyRef

    Represents any Mason object such as @controls, @meta, @error, @namespaces

  13. trait MasonValues extends Encodings with HttpVerbs with MediaType

    Mason values : HttpVerbs, Encodings and so on

  14. trait MasonWrites[-A] extends AnyRef

    Mason serializer: write an implicit to define a serializer for any type

    Mason serializer: write an implicit to define a serializer for any type

    Annotations
    @implicitNotFound("No Mason serializer found for type ${A}. Try to implement an implicit MasonWrites for this type.")
  15. trait MediaType extends AnyRef

    Mason media type

  16. case class Meta(properties: MetaProperty*) extends MasonObject with Product with Serializable

    Represents a @meta object, only present in the root object

    Represents a @meta object, only present in the root object

    properties

    zero or more meta properties ; in case of duplicated property names, the last one override the others.

  17. sealed trait MetaProperty extends Property

    Properties available in @meta object

  18. case class Namespaces(curies: (String, String)*) extends MasonObject with Product with Serializable

    Represents a @namespaces object

    Represents a @namespaces object

    curies

    a list of (prefix, URI) elements

  19. trait Property extends Any

    A basic Mason property

  20. trait PropertyBuilder[T] extends AnyRef
  21. case class Relation(name: String, link: Link) extends MetaProperty with OptionalErrorProperty with Product with Serializable
  22. case class RelationBuilder(name: String) extends PropertyBuilder[Link] with Product with Serializable
  23. case class RootObject(underlying: List[MasonObject]) extends Product with Serializable

    Represents the root of a Mason object

Value Members

  1. val $: MasonKeyBuilder.type

    A shortcut to schidaine.mason.MasonKeyBuilder, useful to create Mason Properties

  2. object Controls extends Serializable

    Serializer for schidaine.mason.Controls

  3. object Encodings extends Encodings

    Standard Encodings

  4. object Error extends Serializable

    Serializer for schidaine.mason.Error

  5. object ErrorProperty
  6. object HttpVerbs extends HttpVerbs

    Standard HTTP Verbs

  7. object JsonObject extends Serializable

    Serializer and helpers for schidaine.mason.JsonObject

  8. object Link extends Serializable

    Serializer for schidaine.mason.Link

  9. object LinkProperty
  10. object Mason
  11. object MasonKeyBuilder extends MasonKeyBuilder
  12. object MasonObject

    Implicit conversions and serializer for schidaine.mason.MasonObject instances.

    Implicit conversions and serializer for schidaine.mason.MasonObject instances.

    import MasonObject._
    val mason =
      Json.obj("data" -> "a small data") ++
      Error($.errorMessage := "There is a big problem")
  13. object MasonValues extends MasonValues

    Mason values : HttpVerbs, Encodings and so on

  14. object MasonWrites
  15. object MediaType extends MediaType

    Mason media type

  16. object Meta extends Serializable

    Serializer for schidaine.mason.Meta

  17. object MetaProperty
  18. object Namespaces extends Serializable

    Serializer for schidaine.mason.Namespaces

  19. object Relation extends Serializable
  20. object RootObject extends Serializable

    Factories and serialiser for schidaine.mason.RootObject

Inherited from AnyRef

Inherited from Any

Ungrouped