diff --git a/topics/server-requests-and-responses.topic b/topics/server-requests-and-responses.topic index 6e92c9e23..018d86f09 100644 --- a/topics/server-requests-and-responses.topic +++ b/topics/server-requests-and-responses.topic @@ -371,9 +371,10 @@

The route you would add is - /tasks/byPriority/{priority} - where {priority} represents a query parameter that you will need to extract at runtime. The - query parameter can have any name you like, but priority seems the obvious choice. + /tasks/byPriority/{priority?} + where {priority?} represents a query parameter that you will need to extract at runtime, + and the question mark is used to indicate that a parameter is optional. The query parameter can have + any name you like, but priority seems the obvious choice.

The process to handle the request can be summarized as follows: @@ -400,7 +401,7 @@ get("/tasks") { ... } //add the following route - get("/tasks/byPriority/{priority}") { + get("/tasks/byPriority/{priority?}") { val priorityAsText = call.parameters["priority"] if (priorityAsText == null) { call.respond(HttpStatusCode.BadRequest) @@ -428,7 +429,7 @@

As summarized above, you have written a handler for the URL - /tasks/byPriority/{priority} + /tasks/byPriority/{priority?} . The symbol priority represents the query parameter that the user has added. Unfortunately, on the server there's @@ -709,7 +710,7 @@ get("/tasks") { ... } - get("/tasks/byPriority/{priority}") { … } + get("/tasks/byPriority/{priority?}") { … } } } @@ -897,7 +898,7 @@ //Code remains the same } - get("/byPriority/{priority}") { + get("/byPriority/{priority?}") { //Code remains the same } @@ -943,7 +944,7 @@ ) } - get("/byPriority/{priority}") { + get("/byPriority/{priority?}") { //Code remains the same } @@ -965,4 +966,4 @@ RESTful API for your task manager that generates JSON files.

- \ No newline at end of file +