!htp #15923 port FormFieldDirectives from spray

This commit is contained in:
Mathias 2014-11-12 14:37:57 +01:00
parent 193dda6e01
commit dbf76cb096
13 changed files with 557 additions and 144 deletions

View file

@ -37,7 +37,7 @@ object HttpCharsetRange {
final def render[R <: Rendering](r: R): r.type = if (qValue < 1.0f) r ~~ "*;q=" ~~ qValue else r ~~ '*'
def matches(charset: HttpCharset) = true
def matchesAll: Boolean = true
def specimen = HttpCharsets.`UTF-8`
def specimen: HttpCharset = HttpCharsets.`UTF-8`
def withQValue(qValue: Float) =
if (qValue == 1.0f) `*` else if (qValue != this.qValue) `*`(qValue.toFloat) else this
}
@ -47,7 +47,7 @@ object HttpCharsetRange {
require(0.0f <= qValue && qValue <= 1.0f, "qValue must be >= 0 and <= 1.0")
def matches(charset: HttpCharset) = this.charset.value.equalsIgnoreCase(charset.value)
def matchesAll: Boolean = false
def specimen = charset
def specimen: HttpCharset = charset
def withQValue(qValue: Float) = One(charset, qValue)
def render[R <: Rendering](r: R): r.type = if (qValue < 1.0f) r ~~ charset ~~ ";q=" ~~ qValue else r ~~ charset
}