Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
54 lines (38 sloc) 1.02 KB

Basic Routing

Express routing definitions have the following pattern:


METHOD can be one of the get, post, put, delete, patch or all.


Respond with Hello World! on the homepage:

app.get("/") { request in
    return Action.ok("Hello World!")

Respond to POST request on the root route /, the application’s home page:"/") { request in
    return Action.ok("Got a POST request")

Respond to a PUT request to the /user route:

app.put("/user") { request in
    return Action.ok("Got a PUT request at /user")

Respond to a DELETE request to the /user route:

app.delete("/user") { request in
    return Action.ok("Got a DELETE request at /user")

Respond to all methods requests on the /user route:

app.all("/user") { request in
    return Action.ok("Got a " + request.method + " request at /user")

Next tutorial: Static files

You can’t perform that action at this time.