perwendel / spark

A simple expressive web framework for java. Spark has a kotlin DSL https://github.com/perwendel/spark-kotlin
Apache License 2.0
9.63k stars 1.56k forks source link

[request] Easier handling of put / get / delete on the same path #1138

Closed OndrejSpanel closed 4 years ago

OndrejSpanel commented 4 years ago

Currently when serving multiple verbs (methods) on the same path, one writes (I use Scala syntax, hopefully it is readable for Java folks as well):

get("/path", (req, resp) => ???)
put("/path", (req, resp) => ???)

Akka Http allows me to write:

pathPrefix("path") {
  get { ctx => ???}
  put { ??? }
}

I suggest adding something like:

path("/path", () => {
  get(".", (req, resp) => ???)
  put("." (req, resp) => ???)
})
ramiresnas commented 4 years ago

Hi @OndrejSpanel ! It is already possible, you should use.

 Spark.path("/path", ()->{
    Spark.get("",(req, resp) -> "" );
    Spark.post("",(req, resp) -> "" );
    Spark.put("",(req, resp) -> "" );
    Spark.patch("",(req, resp) -> "" );
});

I hope help you. Please, close the issue.

OndrejSpanel commented 4 years ago

Thanks.