Skip to content

Commit e95c58e

Browse files
committed
routes, readme and module.scala
1 parent 5529818 commit e95c58e

File tree

3 files changed

+90
-0
lines changed

3 files changed

+90
-0
lines changed

README

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
This is your new Play application
2+
=================================
3+
4+
This file will be packaged with your application when using `activator dist`.
5+
6+
There are several demonstration files available in this template.
7+
8+
Controllers
9+
===========
10+
11+
- HomeController.scala:
12+
13+
Shows how to handle simple HTTP requests.
14+
15+
- AsyncController.scala:
16+
17+
Shows how to do asynchronous programming when handling a request.
18+
19+
- CountController.scala:
20+
21+
Shows how to inject a component into a controller and use the component when
22+
handling requests.
23+
24+
Components
25+
==========
26+
27+
- Module.scala:
28+
29+
Shows how to use Guice to bind all the components needed by your application.
30+
31+
- Counter.scala:
32+
33+
An example of a component that contains state, in this case a simple counter.
34+
35+
- ApplicationTimer.scala:
36+
37+
An example of a component that starts when the application starts and stops
38+
when the application stops.
39+
40+
Filters
41+
=======
42+
43+
- Filters.scala:
44+
45+
Creates the list of HTTP filters used by your application.
46+
47+
- ExampleFilter.scala
48+
49+
A simple filter that adds a header to every response.

app/Module.scala

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

conf/routes

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Routes
2+
# This file defines all application routes (Higher priority routes first)
3+
# ~~~~
4+
5+
# An example controller showing a sample home page
6+
GET / controllers.HomeController.index
7+
# An example controller showing how to use dependency injection
8+
GET /count controllers.CountController.count
9+
# An example controller showing how to write asynchronous code
10+
GET /message controllers.AsyncController.message
11+
12+
# Map static resources from the /public folder to the /assets URL path
13+
GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset)

0 commit comments

Comments
 (0)