blob: 1960b93f169a382d746c22bf2d2a2c8457d36a71 (
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
27
28
29
30
31
32
|
package app
class custom(val path: String, val methods: Seq[String]) extends cask.Endpoint{
type Output = Int
def wrapFunction(ctx: cask.ParamContext, delegate: Delegate): Returned = {
delegate(Map()) match{
case cask.internal.Router.Result.Success(num) =>
cask.internal.Router.Result.Success(
cask.Response("Echo " + num, statusCode = num)
)
case e: cask.internal.Router.Result.Error => e
}
}
// Change this if you want to change
def wrapPathSegment(s: String) = Seq(s)
type Input = Seq[String]
type InputParser[T] = cask.endpoints.QueryParamReader[T]
}
object Endpoints extends cask.MainRoutes{
@custom("/echo/:status", methods = Seq("get"))
def echoStatus(status: String) = {
status.toInt
}
initialize()
}
|