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
import java.io.IOException; | |
import java.lang.reflect.Method; | |
import play.Application; | |
import play.Logger; | |
import play.GlobalSettings; | |
import play.Configuration; | |
import play.mvc.Http.Request; | |
import play.mvc.Action; | |
import play.mvc.Http; |
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
<h1>Testar</h1> |
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
package controllers; | |
import java.lang.annotation.ElementType; | |
import java.lang.annotation.Retention; | |
import java.lang.annotation.RetentionPolicy; | |
import java.lang.annotation.Target; | |
import play.mvc.Action; | |
import play.mvc.Http.Response; | |
import play.mvc.With; |
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
@(message: String) | |
@import play.api.Play | |
@main("Welcome to Play 2.0") { | |
<h1>The current environment is @Play.current.configuration.getString("environment.name")</h1> | |
} |
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
import java.lang.reflect.Method; | |
import play.Application; | |
import play.Logger; | |
import play.GlobalSettings; | |
import play.Configuration; | |
import play.mvc.Http.Request; | |
import play.mvc.Action; | |
import security.basicauth.BasicAuth; |
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
package security.basicauth; | |
import java.io.IOException; | |
import java.lang.reflect.Method; | |
import play.Application; | |
import play.Logger; | |
import play.GlobalSettings; | |
import play.Configuration; | |
import play.mvc.Http.Request; |
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
public static class CorsAction extends Action.Simple { | |
public Result call(Context context) throws Throwable{ | |
Response response = context.response(); | |
response.setHeader("Access-Control-Allow-Origin", *); | |
response.setHeader("Access-Control-Allow-Headers","X-Requested-With"); | |
return delegate.call(context); | |
} | |
} |
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
@With(CorsAction.class) | |
public class CorsController extends Controller { | |
public static Result cors() { | |
return ok("Cors enabled action"); | |
} | |
} |
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
public static class CorsAction extends Action.Simple { | |
public Result call(Context context) throws Throwable{ | |
Response response = context.response(); | |
response.setHeader("Access-Control-Allow-Origin", *); | |
//Handle preflight requests | |
if(context.request().method().equals("OPTIONS")) { | |
response.setHeader("Access-Control-Allow-Methods", "POST"); | |
response.setHeader("Access-Control-Max-Age", "3600"); | |
response.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); |
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
import java.lang.annotation.*; | |
import play.mvc.*; | |
import play.mvc.Http.*; | |
public class CorsComposition { | |
/** | |
* Wraps the annotated action in an <code>CorsAction</code>. | |
*/ | |
@With(CorsAction.class) |