summaryrefslogtreecommitdiff
path: root/cask/test/src/test/cask/Decorator.scala
blob: e8927cf17b9c756b851da634cbe325dd09ad8b53 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package test.cask
import cask.internal.Router.ArgReader
import cask.model.ParamContext


object Decorator extends cask.MainRoutes{
  class myDecorator extends cask.main.Routes.Decorator {
    type InputType = Int

    def handle(ctx: ParamContext) = Map("extra" -> 31337)

    def parseMethodInput[T] = new ArgReader[Int, T, ParamContext] {
      def arity = 1

      def read(ctx: ParamContext, label: String, input: Int) = input.asInstanceOf[T]
    }
  }

  @myDecorator()
  @cask.get("/hello/:world")
  def hello(world: String)(extra: Int) = {
    world + extra
  }

  initialize()
}