Visiting All Routes of a Web Server

Let’s learn how to visit all routes of a web server.

We'll cover the following

The gorilla/mux package offers a Walk function that can be used for visiting all the registered routes of a router—this can be very handy when we want to make sure that every route is registered and is working.

Coding example

The code of walkAll.go, which contains lots of empty handler functions because its purpose is not to test handling functions but to visit them, is as follows (nothing prohibits us from using the same technique on a fully implemented web server):

Get hands-on with 1200+ tech skills courses.