Skip to content

Commit

Permalink
!htp akka#953 Rename HttpApp.route to routes (akka#1070)
Browse files Browse the repository at this point in the history
Fixes akka#953.
  • Loading branch information
jlprat authored and tomrf1 committed Aug 5, 2017
1 parent 3575984 commit b59d5de
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class MinimalHttpApp extends HttpApp {
CompletableFuture<Done> bindingPromise = new CompletableFuture<>();

@Override
protected Route route() {
protected Route routes() {
return route(path("foo", () ->
complete("bar")
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class HttpAppSpec extends AkkaSpec with RequestBuilding with Eventually {
val shutdownPromise = Promise[Done]()
val bindingPromise = Promise[Done]()

override protected def route: Route =
override protected def routes: Route =
path("foo") {
complete("bar")
} ~
Expand Down
5 changes: 2 additions & 3 deletions akka-http/src/main/java/akka/http/javadsl/server/HttpApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void startServer(String host, int port, ServerSettings settings, Optional

CompletionStage<ServerBinding> bindingFuture = Http
.get(theSystem)
.bindAndHandle(route().flow(theSystem, materializer),
.bindAndHandle(routes().flow(theSystem, materializer),
ConnectHttp.toHost(host, port),
settings,
theSystem.log(),
Expand Down Expand Up @@ -162,7 +162,6 @@ protected CompletionStage<Done> waitForShutdownSignal (ActorSystem system) {
/**
* Override to implement the route that will be served by this http server.
*/
protected abstract Route route();

protected abstract Route routes();

}
4 changes: 4 additions & 0 deletions akka-http/src/main/mima-filters/10.0.6.backwards.excludes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Provide routes method in HttpApp #953 Rename of method is OK as class is `@ApiMayChange`
ProblemFilters.exclude[ReversedMissingMethodProblem]("akka.http.javadsl.server.HttpApp.routes")
ProblemFilters.exclude[ReversedMissingMethodProblem]("akka.http.scaladsl.server.HttpApp.routes")
ProblemFilters.exclude[DirectMissingMethodProblem]("akka.http.scaladsl.server.HttpApp.route")
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ abstract class HttpApp extends Directives {
implicit val executionContext = theSystem.dispatcher

val bindingFuture = Http().bindAndHandle(
handler = route,
handler = routes,
interface = host,
port = port,
settings = settings)
Expand Down Expand Up @@ -146,8 +146,7 @@ abstract class HttpApp extends Directives {
}

/**
* Override to implement the route that will be served by this http server.
* Override to implement the routes that will be served by this http server.
*/
protected def route: Route

protected def routes: Route
}
1 change: 1 addition & 0 deletions docs/src/main/paradox/java/http/migration-guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@

* [migration-from-old-http-javadsl](migration-from-old-http-javadsl.md)
* [migration-guide-2.4.x-10.0.x](migration-guide-2.4.x-10.0.x.md)
* [migration-within-10.0.x-Api-May-Change](migration-within-10.0.x-Api-May-Change.md)

@@@
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Migration Guide within Akka HTTP 10.0.x

## General Notes
Akka HTTP is binary backwards compatible within for all version within the 10.0.x range. However, there are a set of APIs
that are marked with the special annotation `@ApiMayChange` which are exempt from this rule, in order to allow them to be
evolved more freely until stabilising them, by removing this annotation.
See @extref:[The @DoNotInherit and @ApiMayChange markers](akka-docs:common/binary-compatibility-rules.html#The_@DoNotInherit_and_@ApiMayChange_markers) for further information.

This migration guide aims to help developers who use these bleeding-edge APIs to migrate between their evolving versions
within patch releases.

## Akka HTTP 10.0.6 -> 10.0.7

### `AkkaHttp#route` has been renamed to `AkkaHttp#routes`

In order to provide a more descriptive name, `AkkaHttp#route` has been renamed to `AkkaHttp#routes`. The previous name
might have led to some confusion by wrongly implying that only one route could be returned in that method.
To migrate to 10.0.6, you must rename the old `route` method to `routes`.
2 changes: 1 addition & 1 deletion docs/src/main/paradox/java/http/routing-dsl/HttpApp.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ in the Akka documentation.
## Introduction

The objective of `HttpApp` is to help you start an HTTP server with just a few lines of code.
This is accomplished just by extending `HttpApp` and implementing the `route()` method.
This is accomplished just by extending `HttpApp` and implementing the `routes()` method.
If desired, `HttpApp` provides different hook methods that can be overridden to change its default behavior.

## Minimal Example
Expand Down
1 change: 1 addition & 0 deletions docs/src/main/paradox/scala/http/migration-guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@

* [migration-from-spray](migration-from-spray.md)
* [migration-guide-2.4.x-10.0.x](migration-guide-2.4.x-10.0.x.md)
* [migration-within-10.0.x-Api-May-Change](migration-within-10.0.x-Api-May-Change.md)

@@@
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Migration Guide within Akka HTTP 10.0.x

## General Notes
Akka HTTP is binary backwards compatible within for all version within the 10.0.x range. However, there are a set of APIs
that are marked with the special annotation `@ApiMayChange` which are exempt from this rule, in order to allow them to be
evolved more freely until stabilising them, by removing this annotation.
See @extref:[The @DoNotInherit and @ApiMayChange markers](akka-docs:common/binary-compatibility-rules.html#The_@DoNotInherit_and_@ApiMayChange_markers) for further information.

This migration guide aims to help developers who use these bleeding-edge APIs to migrate between their evolving versions
within patch releases.

## Akka HTTP 10.0.6 -> 10.0.7

### `AkkaHttp#route` has been renamed to `AkkaHttp#routes`

In order to provide a more descriptive name, `AkkaHttp#route` has been renamed to `AkkaHttp#routes`. The previous name
might have led to some confusion by wrongly implying that only one route could be returned in that method.
To migrate to 10.0.6, you must rename the old `route` method to `routes`.
2 changes: 1 addition & 1 deletion docs/src/main/paradox/scala/http/routing-dsl/HttpApp.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ in the Akka documentation.
## Introduction

The objective of `HttpApp` is to help you start an HTTP server with just a few lines of code.
This is accomplished just by extending `HttpApp` and implementing the `route()` method.
This is accomplished just by extending `HttpApp` and implementing the `routes()` method.
If desired, `HttpApp` provides different hook methods that can be overridden to change its default behavior.

## Minimal Example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void compileOnlySpec() throws Exception {
// Server definition
class MinimalHttpApp extends HttpApp {
@Override
protected Route route() {
protected Route routes() {
return path("hello", () ->
get(() ->
complete("<h1>Say hello to akka-http</h1>")
Expand Down Expand Up @@ -79,7 +79,7 @@ void withSettingsServer() throws ExecutionException, InterruptedException {
class SelfDestroyingHttpApp extends HttpApp {

@Override
protected Route route() {
protected Route routes() {
return path("hello", () ->
get(() ->
complete("<h1>Say hello to akka-http</h1>")
Expand Down Expand Up @@ -114,7 +114,7 @@ void selfDestroyingServer() throws ExecutionException, InterruptedException {
class FailBindingOverrideHttpApp extends HttpApp {

@Override
protected Route route() {
protected Route routes() {
return path("hello", () ->
get(() ->
complete("<h1>Say hello to akka-http</h1>")
Expand Down Expand Up @@ -157,7 +157,7 @@ void ownActorSystem() throws ExecutionException, InterruptedException {
class PostShutdownOverrideHttpApp extends HttpApp {

@Override
protected Route route() {
protected Route routes() {
return path("hello", () ->
get(() ->
complete("<h1>Say hello to akka-http</h1>")
Expand Down
12 changes: 6 additions & 6 deletions docs/src/test/scala/docs/http/scaladsl/HttpAppExampleSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class HttpAppExampleSpec extends WordSpec with Matchers

// Server definition
object WebServer extends HttpApp {
def route: Route =
override def routes: Route =
path("hello") {
get {
complete(HttpEntity(ContentTypes.`text/html(UTF-8)`, "<h1>Say hello to akka-http</h1>"))
Expand All @@ -40,7 +40,7 @@ class HttpAppExampleSpec extends WordSpec with Matchers

// Server definition
object WebServer extends HttpApp {
def route: Route =
override def routes: Route =
path("hello") {
get {
complete(HttpEntity(ContentTypes.`text/html(UTF-8)`, "<h1>Say hello to akka-http</h1>"))
Expand All @@ -63,7 +63,7 @@ class HttpAppExampleSpec extends WordSpec with Matchers

// Server definition
object WebServer extends HttpApp {
def route: Route =
override def routes: Route =
path("hello") {
get {
complete(HttpEntity(ContentTypes.`text/html(UTF-8)`, "<h1>Say hello to akka-http</h1>"))
Expand Down Expand Up @@ -96,7 +96,7 @@ class HttpAppExampleSpec extends WordSpec with Matchers

// Server definition
object WebServer extends HttpApp {
def route: Route =
override def routes: Route =
path("hello") {
get {
complete(HttpEntity(ContentTypes.`text/html(UTF-8)`, "<h1>Say hello to akka-http</h1>"))
Expand All @@ -123,7 +123,7 @@ class HttpAppExampleSpec extends WordSpec with Matchers

// Server definition
object WebServer extends HttpApp {
def route: Route =
override def routes: Route =
path("hello") {
get {
complete(HttpEntity(ContentTypes.`text/html(UTF-8)`, "<h1>Say hello to akka-http</h1>"))
Expand Down Expand Up @@ -151,7 +151,7 @@ class HttpAppExampleSpec extends WordSpec with Matchers

// Server definition
class WebServer extends HttpApp {
def route: Route =
override def routes: Route =
path("hello") {
get {
complete(HttpEntity(ContentTypes.`text/html(UTF-8)`, "<h1>Say hello to akka-http</h1>"))
Expand Down

0 comments on commit b59d5de

Please sign in to comment.