Skip to content

Commit

Permalink
+pro,hco,par Make sure that things build on both 2.10 and 2.11
Browse files Browse the repository at this point in the history
  • Loading branch information
bantonsson committed Jun 26, 2014
1 parent 8ff980c commit e32ba9c
Show file tree
Hide file tree
Showing 12 changed files with 450 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class HttpServerExampleSpec
case HttpRequest(GET, Uri.Path("/"), _, _, _)
HttpResponse(
entity = HttpEntity(MediaTypes.`text/html`,
<html><body>Hello world!</body></html>.toString))
"<html><body>Hello world!</body></html>"))

case HttpRequest(GET, Uri.Path("/ping"), _, _, _) HttpResponse(entity = "PONG!")
case HttpRequest(GET, Uri.Path("/crash"), _, _, _) sys.error("BOOM!")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public abstract class Host {
/**
* The constant representing an empty Host.
*/
public static final Host EMPTY = akka.http.model.Uri$Host$Empty$.MODULE$;
public static final Host EMPTY = akka.http.model.Uri.getHostEmpty();

/**
* Parse the given Host string using the default charset and parsing-mode.
Expand Down
6 changes: 3 additions & 3 deletions akka-http-core/src/main/java/akka/http/model/japi/Uri.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ public static interface Parameter {
*/
public abstract Uri fragment(Option<String> fragment);

public static final akka.http.model.Uri.ParsingMode STRICT = akka.http.model.Uri$ParsingMode$Strict$.MODULE$;
public static final akka.http.model.Uri.ParsingMode RELAXED = akka.http.model.Uri$ParsingMode$Relaxed$.MODULE$;
public static final akka.http.model.Uri.ParsingMode RELAXED_WITH_RAW_QUERY = akka.http.model.Uri$ParsingMode$RelaxedWithRawQuery$.MODULE$;
public static final akka.http.model.Uri.ParsingMode STRICT = akka.http.model.Uri.getParsingModeStrict();
public static final akka.http.model.Uri.ParsingMode RELAXED = akka.http.model.Uri.getParsingModeRelaxed();
public static final akka.http.model.Uri.ParsingMode RELAXED_WITH_RAW_QUERY = akka.http.model.Uri.getParsingModeRelaxedWithRawQuery();

/**
* Creates a default Uri to be modified using the modification methods.
Expand Down
4 changes: 2 additions & 2 deletions akka-http-core/src/main/java/akka/http/model/japi/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static <T, U extends T> Producer<U> upcastProducer(Producer<T> p) {
}
@SuppressWarnings("unchecked")
public static scala.collection.immutable.Map<String, String> convertMapToScala(Map<String, String> map) {
return Map$.MODULE$.apply(scala.collection.JavaConverters.asScalaMapConverter(map).asScala().toSeq());
return Map$.MODULE$.apply(scala.collection.JavaConverters.mapAsScalaMapConverter(map).asScala().toSeq());
}
@SuppressWarnings("unchecked") // contains an upcast
public static <T, U extends T> scala.Option<U> convertOptionToScala(Option<T> o) {
Expand All @@ -53,7 +53,7 @@ public static <T> scala.Option<T> scalaNone() {

@SuppressWarnings("unchecked")
public static <T, U extends T> Seq<U> convertIterable(Iterable<T> els) {
return scala.collection.JavaConverters.asScalaIterableConverter((Iterable<U>)els).asScala().toVector();
return scala.collection.JavaConverters.iterableAsScalaIterableConverter((Iterable<U>)els).asScala().toVector();
}
@SuppressWarnings("unchecked")
public static <T, U extends T> Seq<U> convertArray(T[] els) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public static CacheDirective MIN_FRESH(long deltaSeconds) {
public static CacheDirective NO_CACHE(String... fieldNames) {
return akka.http.model.headers.CacheDirectives.no$minuscache$.MODULE$.apply(fieldNames);
}
public static final CacheDirective PUBLIC = akka.http.model.headers.CacheDirectives.public$.MODULE$;
public static final CacheDirective PUBLIC = akka.http.model.headers.CacheDirectives.getPublic();
public static CacheDirective PRIVATE(String... fieldNames) {
return akka.http.model.headers.CacheDirectives.private$.MODULE$.apply(fieldNames);
return akka.http.model.headers.CacheDirectives.createPrivate(fieldNames);
}
public static final CacheDirective PROXY_REVALIDATE = akka.http.model.headers.CacheDirectives.proxy$minusrevalidate$.MODULE$;
public static CacheDirective S_MAXAGE(long deltaSeconds) {
Expand Down
11 changes: 11 additions & 0 deletions akka-http-core/src/main/scala/akka/http/model/Uri.scala
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,10 @@ object Uri {
def apply(address: Inet4Address): IPv4Host = IPv4Host(address.getAddress, address.getHostAddress)
def apply(address: Inet6Address): IPv6Host = IPv6Host(address.getAddress, address.getHostAddress)
}

/** Java API */
def getHostEmpty: Host = Host.Empty

sealed abstract class NonEmptyHost extends Host {
def isEmpty = false
def toOption = Some(this)
Expand Down Expand Up @@ -596,6 +600,13 @@ object Uri {
}
}

/** Java API */
def getParsingModeStrict: ParsingMode = ParsingMode.Strict
/** Java API */
def getParsingModeRelaxed: ParsingMode = ParsingMode.Relaxed
/** Java API */
def getParsingModeRelaxedWithRawQuery: ParsingMode = ParsingMode.RelaxedWithRawQuery

// http://tools.ietf.org/html/rfc3986#section-5.2.2
private[http] def resolve(scheme: String, userinfo: String, host: Host, port: Int, path: Path, query: Query,
fragment: Option[String], base: Uri): Uri = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ object CacheDirective {
sealed trait RequestDirective extends CacheDirective
sealed trait ResponseDirective extends CacheDirective

private final case class CustomCacheDirective(name: String, content: Option[String])
final case class CustomCacheDirective(name: String, content: Option[String])
extends RequestDirective with ResponseDirective with ValueRenderable {
def render[R <: Rendering](r: R): r.type = content match {
case Some(s) r ~~ name ~~ '=' ~~# s
Expand Down Expand Up @@ -91,12 +91,18 @@ object CacheDirectives {
// http://tools.ietf.org/html/rfc7234#section-5.2.2.5
case object `public` extends SingletonValueRenderable with ResponseDirective

/** Java API */
def getPublic: ResponseDirective = `public`

// http://tools.ietf.org/html/rfc7234#section-5.2.2.6
final case class `private`(fieldNames: immutable.Seq[String]) extends FieldNamesDirective with ResponseDirective
object `private` {
@varargs def apply(fieldNames: String*): `private` = apply(immutable.Seq(fieldNames: _*))
}

/** Java API */
@varargs def createPrivate(fieldNames: String*): ResponseDirective = `private`.apply(immutable.Seq(fieldNames: _*))

// http://tools.ietf.org/html/rfc7234#section-5.2.2.7
case object `proxy-revalidate` extends SingletonValueRenderable with ResponseDirective

Expand Down
20 changes: 10 additions & 10 deletions akka-http-core/src/test/scala/akka/http/TestServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ object TestServer extends App {

lazy val index = HttpResponse(
entity = HttpEntity(MediaTypes.`text/html`,
<html>
<body>
<h1>Say hello to <i>akka-http-core</i>!</h1>
<p>Defined resources:</p>
<ul>
<li><a href="/ping">/ping</a></li>
<li><a href="/crash">/crash</a></li>
</ul>
</body>
</html>.toString()))
"""|<html>
| <body>
| <h1>Say hello to <i>akka-http-core</i>!</h1>
| <p>Defined resources:</p>
| <ul>
| <li><a href="/ping">/ping</a></li>
| <li><a href="/crash">/crash</a></li>
| </ul>
| </body>
|</html>""".stripMargin))
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import language.experimental.macros

import reflect.macros.Context

import HasCompat._

// Typically the contents of this object will be imported via val alias `poly` in the shapeless package object.
object PolyDefns extends Cases {
/**
Expand Down Expand Up @@ -52,6 +54,7 @@ object PolyDefns extends Cases {

def materializeFromValueImpl[P: c.WeakTypeTag, FT: c.WeakTypeTag, T: c.WeakTypeTag](c: Context): c.Expr[Case[P, FT :: HNil]] = {
import c.universe._
import compat._

val pTpe = weakTypeOf[P]
val ftTpe = weakTypeOf[FT]
Expand Down Expand Up @@ -227,6 +230,7 @@ object Poly extends PolyInst {

def liftFnImpl(c: Context)(f: c.Expr[Any]): c.Expr[Poly] = {
import c.universe._
import compat._
import Flag._

val pendingSuperCall = Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), List())
Expand Down
Loading

0 comments on commit e32ba9c

Please sign in to comment.