Skip to content
This repository was archived by the owner on Aug 7, 2024. It is now read-only.

Commit 695deea

Browse files
Initial commit
0 parents  commit 695deea

19 files changed

+616
-0
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
build
2+
logs
3+
target
4+
/.idea
5+
/.idea_modules
6+
/.classpath
7+
/.project
8+
/.settings
9+
/RUNNING_PID

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Scala Play GitHub API

app/Module.scala

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import com.google.inject.AbstractModule
2+
import java.time.Clock
3+
4+
/**
5+
* This class is a Guice module that tells Guice how to bind several
6+
* different types. This Guice module is created when the Play
7+
* application starts.
8+
*
9+
* Play will automatically use any class called `Module` that is in
10+
* the root package. You can create modules in other locations by
11+
* adding `play.modules.enabled` settings to the `application.conf`
12+
* configuration file.
13+
*/
14+
class Module extends AbstractModule {
15+
16+
override def configure() = {
17+
// Use the system clock as the default implementation of Clock
18+
bind(classOf[Clock]).toInstance(Clock.systemDefaultZone)
19+
}
20+
21+
}

app/controllers/HomeController.scala

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package controllers
2+
3+
import javax.inject._
4+
5+
import play.api.mvc._
6+
7+
/**
8+
* This controller creates an `Action` to handle HTTP requests to the
9+
* application's home page.
10+
*/
11+
@Singleton
12+
class HomeController @Inject()(cc: ControllerComponents) (implicit assetsFinder: AssetsFinder)
13+
extends AbstractController(cc) {
14+
15+
/**
16+
* Create an Action to render an HTML page with a welcome message.
17+
* The configuration in the `routes` file means that this method
18+
* will be called when the application receives a `GET` request with
19+
* a path of `/`.
20+
*/
21+
def index = Action {
22+
Ok(views.html.index("Your new application is ready."))
23+
}
24+
25+
}

app/filters/ExampleFilter.scala

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package filters
2+
3+
import javax.inject._
4+
import play.api.mvc._
5+
import scala.concurrent.ExecutionContext
6+
7+
/**
8+
* This is a simple filter that adds a header to all requests. It's
9+
* added to the application's list of filters by the
10+
* [[Filters]] class.
11+
*
12+
* @param ec This class is needed to execute code asynchronously.
13+
* It is used below by the `map` method.
14+
*/
15+
@Singleton
16+
class ExampleFilter @Inject()(implicit ec: ExecutionContext) extends EssentialFilter {
17+
override def apply(next: EssentialAction) = EssentialAction { request =>
18+
next(request).map { result =>
19+
result.withHeaders("X-ExampleFilter" -> "foo")
20+
}
21+
}
22+
}

app/views/index.scala.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@(message: String)(implicit assetsFinder: AssetsFinder)
2+
3+
@main("Welcome to Play", assetsFinder) {
4+
5+
@welcome(message, style = "scala")
6+
7+
}

app/views/main.scala.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@(title: String, assetsFinder: AssetsFinder)(content: Html)
2+
3+
<!DOCTYPE html>
4+
<html lang="en">
5+
<head>
6+
<title>@title</title>
7+
<link rel="stylesheet" media="screen" href="@assetsFinder.path("stylesheets/main.css")">
8+
<link rel="shortcut icon" type="image/png" href="@assetsFinder.path("images/favicon.png")">
9+
</head>
10+
<body>
11+
@content
12+
</body>
13+
</html>

app/views/welcome.scala.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@(message: String, style: String = "scala")
2+
3+
@defining(play.core.PlayVersion.current) { version =>
4+
5+
<section id="top">
6+
<div class="wrapper">
7+
<h1>@message</h1>
8+
</div>
9+
</section>
10+
11+
<div id="content" class="wrapper doc">
12+
<article>
13+
14+
<h2>Welcome to Play</h2>
15+
16+
</article>
17+
18+
19+
</div>
20+
}

build.sbt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name := """play-scala-starter-example"""
2+
3+
version := "1.0-SNAPSHOT"
4+
5+
lazy val root = (project in file(".")).enablePlugins(PlayScala)
6+
7+
resolvers += Resolver.sonatypeRepo("snapshots")
8+
9+
scalaVersion := "2.12.7"
10+
11+
crossScalaVersions := Seq("2.11.12", "2.12.7")
12+
13+
libraryDependencies += guice
14+
libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "3.1.2" % Test
15+
libraryDependencies += "com.h2database" % "h2" % "1.4.197"

0 commit comments

Comments
 (0)