Skip to content

Instantly share code, notes, and snippets.

@edgarmueller
Last active July 17, 2017 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edgarmueller/cef297f778db73a5887f1a01fae7ec80 to your computer and use it in GitHub Desktop.
Save edgarmueller/cef297f778db73a5887f1a01fae7ec80 to your computer and use it in GitHub Desktop.
package controllers;
import play.cache.SyncCacheApi;
import play.mvc.*;
import views.html.*;
import javax.inject.Inject;
/**
* This controller contains an action to handle HTTP requests
* to the application's home page.
*/
public class HomeController extends Controller {
private final views.html.index template;
@Inject
public HomeController(views.html.index template, SyncCacheApi cacheApi) {
this.template = template;
cacheApi.set("hello", "hello there!");
}
/**
* An action that renders an HTML page with a welcome message.
* The configuration in the <code>routes</code> file means that
* this method will be called when the application receives a
* <code>GET</code> request with a path of <code>/</code>.
*/
public Result index() {
return ok(template.render("Your new application is ready."));
}
}
@import play.cache.SyncCacheApi
@this(cacheApi: SyncCacheApi)
@(message: String)
@main("Welcome to Play") {
@cacheApi.get[String]("hello")
@welcome(message, style = "java")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment