Grokking Advanced Go
Vote

0% completed

​

Routing with ServeMux

Output:

GET /orders 200 "all orders" POST /orders 201 "order created" GET /orders/1001 200 "order number 1001" DELETE /orders 405 "Method Not Allowed\n" GET /customers 404 "404 page not found\n"

Three registrations produced five different results, and no third-party router was involved. The method and the path are both part of each pattern, so POST /orders runs a different function than GET /orders. The handler reads the value of {id} with r.PathValue. The `DELETE

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content