All Downloads are FREE. Search and download functionalities are using the official Maven repository.

enumeratum.PlayUppercasePathBindableEnum.scala Maven / Gradle / Ivy

package enumeratum

import play.api.mvc.PathBindable
import play.api.routing.sird.PathBindableExtractor

trait PlayUppercasePathBindableEnum[A <: EnumEntry] { self: Enum[A] =>

  /**
    * Implicit path binder for Play's default router
    */
  implicit val pathBindable: PathBindable[A] =
    UrlBinders.pathBinderUppercaseOnly(self)

  /**
    * Binder for [[play.api.routing.sird]] router
    *
    * Example:
    *
    * {{{
    *  import play.api.routing.sird._
    *  import play.api.routing._
    *  import play.api.mvc._
    *
    *  Router.from {
    *    case GET(p"/hello/${Greeting.fromPath(greeting)}") => Action {
    *      Results.Ok(s"$greeting")
    *    }
    *  }
    * }}}
    */
  lazy val fromPath = new PathBindableExtractor[A]
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy