spice.http.HeaderKey.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spice-core_sjs1_3 Show documentation
Show all versions of spice-core_sjs1_3 Show documentation
Core functionality leveraged and shared by most other sub-projects of Spice.
package spice.http
trait HeaderKey {
def key: String
protected def commaSeparated: Boolean
def get(headers: Headers): Option[String] = all(headers).headOption
def all(headers: Headers): List[String] = if (commaSeparated) {
headers.get(this).flatMap(_.split(',').map(_.trim))
} else {
headers.get(this)
}
}
object HeaderKey {
def apply(key: String): StringHeaderKey = new StringHeaderKey(key)
}