This repository has been archived by the owner on Apr 30, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
155 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[*] | ||
charset=utf-8 | ||
end_of_line=lf | ||
insert_final_newline=true | ||
trim_trailing_whitespace = true | ||
indent_style=space | ||
indent_size=2 | ||
|
||
|
||
[*.java] | ||
indent_style=space | ||
indent_size=4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-J-Xms512M | ||
-J-Xmx4096M | ||
-J-Xss2M | ||
-J-XX:MaxMetaspaceSize=1024M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
This software is licensed under the Apache 2 license, quoted below. | ||
|
||
Copyright 2016 Lightbend Inc. [http://www.lightbend.com] | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
use this file except in compliance with the License. You may obtain a copy of | ||
the License at | ||
|
||
[http://www.apache.org/licenses/LICENSE-2.0] | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
License for the specific language governing permissions and limitations under | ||
the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# CORS recipe for Lagom's Javadsl | ||
|
||
|
||
``` | ||
curl -H "Access-Control-Request-Method: GET" \ | ||
-H "Access-Control-Request-Headers: origin, x-requested-with" \ | ||
-H "Origin: http://www.some-domain.com" \ | ||
-X OPTIONS http://localhost:9000/api/hello/123 -v | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
organization in ThisBuild := "com.lightbend.lagom.recipes" | ||
version in ThisBuild := "1.0-SNAPSHOT" | ||
|
||
// the Scala version that will be used for cross-compiled libraries | ||
scalaVersion in ThisBuild := "2.11.8" | ||
|
||
lazy val `cors-java` = (project in file(".")) | ||
.aggregate(`cors-java-api`, `cors-java-impl`) | ||
|
||
lazy val `cors-java-api` = (project in file("cors-java-api")) | ||
.settings( | ||
libraryDependencies ++= Seq( | ||
lagomJavadslApi | ||
) | ||
) | ||
|
||
lazy val `cors-java-impl` = (project in file("cors-java-impl")) | ||
.enablePlugins(LagomJava) | ||
.settings( | ||
libraryDependencies ++= Seq( | ||
) | ||
) | ||
.dependsOn(`cors-java-api`) | ||
|
||
lagomCassandraEnabled in ThisBuild := false | ||
lagomKafkaEnabled in ThisBuild := false |
28 changes: 28 additions & 0 deletions
28
...cors-java-api/src/main/java/com/lightbend/lagom/recipes/corsjava/api/CorsjavaService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright (C) 2016 Lightbend Inc. <http://www.lightbend.com> | ||
*/ | ||
package com.lightbend.lagom.recipes.corsjava.api; | ||
|
||
import akka.NotUsed; | ||
import com.lightbend.lagom.javadsl.api.Descriptor; | ||
import com.lightbend.lagom.javadsl.api.Service; | ||
import com.lightbend.lagom.javadsl.api.ServiceCall; | ||
|
||
import static com.lightbend.lagom.javadsl.api.Service.named; | ||
import static com.lightbend.lagom.javadsl.api.Service.pathCall; | ||
|
||
public interface CorsjavaService extends Service { | ||
|
||
/** | ||
* Example: curl http://localhost:9000/api/hello/Alice | ||
*/ | ||
ServiceCall<NotUsed, String> hello(String id); | ||
|
||
@Override | ||
default Descriptor descriptor() { | ||
return named("corsjava").withCalls( | ||
pathCall("/api/hello/:id", this::hello) | ||
).withAutoAcl(true); | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
...ors-java-impl/src/main/java/com/lightbend/lagom/recipes/corsjava/impl/CorsjavaModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright (C) 2016 Lightbend Inc. <http://www.lightbend.com> | ||
*/ | ||
package com.lightbend.lagom.recipes.corsjava.impl; | ||
|
||
import com.google.inject.AbstractModule; | ||
import com.lightbend.lagom.javadsl.server.ServiceGuiceSupport; | ||
import com.lightbend.lagom.recipes.corsjava.api.CorsjavaService; | ||
|
||
/** | ||
* The module that binds the CorsjavaService so that it can be served. | ||
*/ | ||
public class CorsjavaModule extends AbstractModule implements ServiceGuiceSupport { | ||
@Override | ||
protected void configure() { | ||
bindService(CorsjavaService.class, CorsjavaServiceImpl.class); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...ava-impl/src/main/java/com/lightbend/lagom/recipes/corsjava/impl/CorsjavaServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright (C) 2016 Lightbend Inc. <http://www.lightbend.com> | ||
*/ | ||
package com.lightbend.lagom.recipes.corsjava.impl; | ||
|
||
import akka.NotUsed; | ||
import com.lightbend.lagom.javadsl.api.ServiceCall; | ||
import com.lightbend.lagom.recipes.corsjava.api.CorsjavaService; | ||
|
||
import javax.inject.Inject; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
/** | ||
* Implementation of the CorsjavaService. | ||
*/ | ||
public class CorsjavaServiceImpl implements CorsjavaService { | ||
|
||
|
||
@Inject | ||
public CorsjavaServiceImpl() { | ||
} | ||
|
||
@Override | ||
public ServiceCall<NotUsed, String> hello(String id) { | ||
return request -> CompletableFuture.completedFuture(id); | ||
} | ||
|
||
|
||
} |
6 changes: 6 additions & 0 deletions
6
cors/cors-java/cors-java-impl/src/main/resources/application.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# | ||
# Copyright (C) 2016 Lightbend Inc. <http://www.lightbend.com> | ||
# | ||
play.crypto.secret=whatever | ||
play.modules.enabled += com.lightbend.lagom.recipes.corsjava.impl.CorsjavaModule | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# | ||
# Copyright (C) 2016 Lightbend Inc. <https://www.lightbend.com> | ||
# | ||
sbt.version=0.13.15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// The Lagom plugin | ||
addSbtPlugin("com.lightbend.lagom" % "lagom-sbt-plugin" % "1.3.7") | ||
// Needed for importing the project into Eclipse | ||
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.1.0") |