Skip to content
This repository has been archived by the owner on Apr 30, 2019. It is now read-only.

Commit

Permalink
Adds a non-CORS project
Browse files Browse the repository at this point in the history
  • Loading branch information
ignasi35 committed Aug 24, 2017
1 parent 01f2478 commit 9f8de2f
Show file tree
Hide file tree
Showing 11 changed files with 155 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cors/cors-java/.editorconfig
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
4 changes: 4 additions & 0 deletions cors/cors-java/.sbtopts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-J-Xms512M
-J-Xmx4096M
-J-Xss2M
-J-XX:MaxMetaspaceSize=1024M
15 changes: 15 additions & 0 deletions cors/cors-java/LICENSE
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.
9 changes: 9 additions & 0 deletions cors/cors-java/README.md
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
```
26 changes: 26 additions & 0 deletions cors/cors-java/build.sbt
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
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);
}

}
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);
}
}
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);
}


}
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

4 changes: 4 additions & 0 deletions cors/cors-java/project/build.properties
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
4 changes: 4 additions & 0 deletions cors/cors-java/project/plugins.sbt
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")

0 comments on commit 9f8de2f

Please sign in to comment.