Skip to content

Instantly share code, notes, and snippets.

@danielkmariam
Created October 31, 2018 11:16
Show Gist options
  • Save danielkmariam/8e1ee85078ebfec878444643e360eeda to your computer and use it in GitHub Desktop.
Save danielkmariam/8e1ee85078ebfec878444643e360eeda to your computer and use it in GitHub Desktop.
package controllers
import io.circe.generic.auto._
import io.circe.syntax._
import javax.inject._
import play.api._
import play.api.mvc._
/**
* This controller creates an `Action` to handle HTTP requests to the
* application's home page.
*/
@Singleton
class HomeController @Inject()(cc: ControllerComponents) extends AbstractController(cc) with Circe {
case class Person(name: String, age: Int)
val daniel = Person("Dan", 18)
/**
* Create an Action to render an HTML page.
*
* The configuration in the `routes` file means that this method
* will be called when the application receives a `GET` request with
* a path of `/`.
*/
def index() = Action { implicit request: Request[AnyContent] =>
Ok(daniel.asJson)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment