Skip to content

Commit 2694ba4

Browse files
marcoboinoorul
authored andcommitted
feat(api): Add support for HTTP override (spark-jobserver#883)
1 parent 530aeda commit 2694ba4

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Also see [Chinese docs / 中文](doc/chinese/job-server.md).
5050
- [Context configuration](#context-configuration)
5151
- [Other configuration settings](#other-configuration-settings)
5252
- [Job Result Serialization](#job-result-serialization)
53+
- [HTTP Override](#http-override)
5354
- [Clients](#clients)
5455
- [Contribution and Development](#contribution-and-development)
5556
- [Publishing packages](#publishing-packages)
@@ -791,6 +792,19 @@ serialized properly:
791792
792793
If we encounter a data type that is not supported, then the entire result will be serialized to a string.
793794
795+
### HTTP Override
796+
797+
Spark Job Server offers HTTP override functionality.
798+
Often reverse proxies and firewall implement access limitations to, for example, DELETE and PUT requests.
799+
HTTP override allows overcoming these limitations by wrapping, for example, a DELETE request into a POST request.
800+
801+
Requesting the destruction of a context can be accomplished through HTTP override using the following syntax:
802+
803+
$ curl -X POST "localhost:8090/contexts/test_context?_method=DELETE"
804+
805+
Here, a DELETE request is passed to Spark Job Server "through" a POST request.
806+
807+
794808
## Clients
795809
796810
Spark Jobserver project has a

job-server/src/main/scala/spark/jobserver/WebApi.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,10 @@ class WebApi(system: ActorSystem,
139139
val logger = LoggerFactory.getLogger(getClass)
140140

141141
val myRoutes = cors {
142-
binaryRoutes ~ jarRoutes ~ contextRoutes ~ jobRoutes ~
143-
dataRoutes ~ healthzRoutes ~ otherRoutes
142+
overrideMethodWithParameter("_method") {
143+
binaryRoutes ~ jarRoutes ~ contextRoutes ~ jobRoutes ~
144+
dataRoutes ~ healthzRoutes ~ otherRoutes
145+
}
144146
}
145147

146148
lazy val authenticator: AuthMagnet[AuthInfo] = {

0 commit comments

Comments
 (0)