=htp a few small things that got lost in the #17988 merge
This commit is contained in:
parent
26d2910b68
commit
58e78757de
5 changed files with 13 additions and 21 deletions
|
|
@ -4,14 +4,11 @@
|
|||
|
||||
package docs.http.javadsl.server;
|
||||
|
||||
import akka.http.javadsl.model.HttpRequest;
|
||||
import akka.http.javadsl.model.StatusCodes;
|
||||
import akka.http.javadsl.server.*;
|
||||
import akka.http.javadsl.server.values.Parameters;
|
||||
import akka.http.javadsl.server.values.PathMatcher;
|
||||
import akka.http.javadsl.server.values.PathMatchers;
|
||||
import akka.http.javadsl.testkit.JUnitRouteTest;
|
||||
import akka.http.javadsl.testkit.TestRoute;
|
||||
import org.junit.Test;
|
||||
|
||||
public class PathDirectiveExampleTest extends JUnitRouteTest {
|
||||
|
|
@ -82,9 +79,4 @@ public class PathDirectiveExampleTest extends JUnitRouteTest {
|
|||
);
|
||||
//#path-examples
|
||||
}
|
||||
|
||||
// FIXME: remove once #17988 is merged
|
||||
public static <T> Route handleWith1(RequestVal<T> val, Object o) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -64,7 +64,8 @@ about the number of handled arguments easier. For example, a :class:`Handler1[St
|
|||
``Function2[RequestContext, String, RouteResult]``. You can think of handlers as hot-dogs, where each ``T``
|
||||
type represents a sausage, put between the "buns" which are ``RequestContext`` and ``RouteResult``.
|
||||
|
||||
In Java 8 handlers can be provided as function literals or method references. The example from before then looks like this:
|
||||
In Java 8 handlers can be provided as function literals or method references. The previous example can then be written
|
||||
like this:
|
||||
|
||||
.. includecode:: /../../akka-http-tests-java8/src/test/java/docs/http/javadsl/server/HandlerExampleDocTest.java
|
||||
:include: handler2-java8-example-full
|
||||
|
|
@ -76,11 +77,9 @@ In Java 8 handlers can be provided as function literals or method references. Th
|
|||
if one type of a handler does not match the given values, *all* possible candidates would be printed in the error message
|
||||
(22 of them), instead of just the one arity-matching method, pointing out that the type does not match.
|
||||
|
||||
We opted for better error messages as we feel this is more helpful when developing applications,
|
||||
instead of having one overloaded method which looks nice when everything works, but procudes hard to read error
|
||||
messages if something does not match up.
|
||||
|
||||
|
||||
We opted for better error messages as we feel this is more helpful when developing applications,
|
||||
instead of having one overloaded method which looks nice when everything works, but procudes hard to read error
|
||||
messages if something does not match up.
|
||||
|
||||
Providing Handlers by Reflection
|
||||
--------------------------------
|
||||
|
|
|
|||
|
|
@ -3,12 +3,14 @@
|
|||
*/
|
||||
|
||||
import akka.http.javadsl.server.HandlerBindingTest;
|
||||
import docs.http.javadsl.server.HandlerExampleDocTest;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
|
||||
@RunWith(Suite.class)
|
||||
@Suite.SuiteClasses({
|
||||
HandlerBindingTest.class
|
||||
HandlerBindingTest.class,
|
||||
HandlerExampleDocTest.class
|
||||
})
|
||||
public class AllJavaTests {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,11 +66,11 @@ public class HandlerExampleDocTest extends JUnitRouteTest {
|
|||
public void testCalculator() {
|
||||
//#handler2-example-full
|
||||
class TestHandler extends akka.http.javadsl.server.AllDirectives {
|
||||
RequestVal<Integer> xParam = Parameters.intValue("x");
|
||||
RequestVal<Integer> yParam = Parameters.intValue("y");
|
||||
final RequestVal<Integer> xParam = Parameters.intValue("x");
|
||||
final RequestVal<Integer> yParam = Parameters.intValue("y");
|
||||
|
||||
RequestVal<Integer> xSegment = PathMatchers.intValue();
|
||||
RequestVal<Integer> ySegment = PathMatchers.intValue();
|
||||
final RequestVal<Integer> xSegment = PathMatchers.intValue();
|
||||
final RequestVal<Integer> ySegment = PathMatchers.intValue();
|
||||
|
||||
//#handler2
|
||||
final Handler2<Integer, Integer> multiply =
|
||||
|
|
|
|||
|
|
@ -6,10 +6,9 @@ package akka.http.javadsl.server.directives
|
|||
|
||||
import java.lang.reflect.{ Method, ParameterizedType }
|
||||
|
||||
import akka.http.javadsl.model.{ Uri, ContentType, StatusCode, HttpResponse }
|
||||
import akka.http.impl.server.RouteStructure._
|
||||
import akka.http.impl.server._
|
||||
import akka.http.javadsl.model.{ ContentType, HttpResponse, StatusCode }
|
||||
import akka.http.javadsl.model.{ ContentType, HttpResponse, StatusCode, Uri }
|
||||
import akka.http.javadsl.server._
|
||||
|
||||
import scala.annotation.varargs
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue