Skip to content

Commit

Permalink
Merge branch 'master' of github.com:lihaoyi/cask
Browse files Browse the repository at this point in the history
  • Loading branch information
lihaoyi committed Nov 15, 2021
2 parents 72de851 + e8de393 commit 2a3f8a2
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cask/src/cask/endpoints/WebEndpoints.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class delete(val path: String, override val subpath: Boolean = false) extends We
val methods = Seq("delete")
}
class route(val path: String, val methods: Seq[String], override val subpath: Boolean = false) extends WebEndpoint
class options(val path: String, override val subpath: Boolean = false) extends WebEndpoint{
val methods = Seq("options")
}

abstract class QueryParamReader[T]
extends ArgReader[Seq[String], T, cask.model.Request]{
Expand Down
1 change: 1 addition & 0 deletions cask/src/cask/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ package object cask {
type postJson = endpoints.postJson
type getJson = endpoints.getJson
type postForm = endpoints.postForm
type options = endpoints.options

// main
type MainRoutes = main.MainRoutes
Expand Down
6 changes: 6 additions & 0 deletions example/httpMethods/app/src/HttpMethods.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,11 @@ object HttpMethods extends cask.MainRoutes{
"security_by_obscurity"
}

@cask.route("/api", methods = Seq("options"))
def cors(request: cask.Request) = {
"allow_cors"
}


initialize()
}
1 change: 1 addition & 0 deletions example/httpMethods/app/test/src/ExampleTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ object ExampleTests extends TestSuite{
requests.put(s"$host/login", check = false).statusCode ==> 405
requests.delete(s"$host/session").text() ==> "delete_the_session"
requests.get.copy(verb="secretmethod")(s"$host/session").text() ==> "security_by_obscurity"
requests.options(s"$host/api").text() ==> "allow_cors"
}
}
}
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ courtesy of EJ Technologies
### 0.7.13

- Update Castor to 0.1.8
- Add `@cask.options` decorator

### 0.7.11

Expand Down

0 comments on commit 2a3f8a2

Please sign in to comment.