summaryrefslogblamecommitdiff
path: root/example/endpoints/app/src/Endpoints.scala
blob: b934769c0c72b978b76e0142c6262be58fe27e37 (plain) (tree)
1
2
3
4
5
6
7
8

           
                                                                               
                   

                                                                            

                                                    


     















                                                          
package app

class custom(val path: String, val methods: Seq[String]) extends cask.Endpoint{
  type Output = Int
  type InnerReturned = Int
  def wrapFunction(ctx: cask.Request, delegate: Delegate): OuterReturned = {
    delegate(Map()).map{num =>
      cask.Response("Echo " + num, statusCode = num)
    }
  }

  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()
}