diff options
Diffstat (limited to 'example/endpoints/app/src/Endpoints.scala')
-rw-r--r-- | example/endpoints/app/src/Endpoints.scala | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/example/endpoints/app/src/Endpoints.scala b/example/endpoints/app/src/Endpoints.scala new file mode 100644 index 0000000..1960b93 --- /dev/null +++ b/example/endpoints/app/src/Endpoints.scala @@ -0,0 +1,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() +} |