Created
October 31, 2018 11:16
-
-
Save danielkmariam/8e1ee85078ebfec878444643e360eeda to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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