Versionary v0.2.0 Versionary.Plug.VerifyHeader

Use this plug to verify a version string in the header.

Example

plug Versionary.Plug.VerifyHeader, versions: ["application/vnd.app.v1+json"]

If multiple versions are passed to this plug and at least one matches the version will be considered valid.

Example

plug Versionary.Plug.VerifyHeader, versions: ["application/vnd.app.v1+json",
                                              "application/vnd.app.v2+json"]

It’s also possible to verify versions against configured mime types. If multiple mime types are passed and at least one matches the version will be considered valid.

Example

config :mime, :types, %{
  "application/vnd.app.v1+json" => [:v1]
}
plug Versionary.Plug.VerifyHeader, accepts: [:v1]

By default, this plug will look at the Accept header for the version string to verify against. If you’d like to verify against another header specify the header you’d like to verify against in the header option.

Example

plug Versionary.Plug.VerifyHeader, header: "accept",
                                   versions: ["application/vnd.app.v1+json"]