New Routes
How Route Registration Works
Simple Registration
In a simple way, we can instantiate a route by calling the method RegisterRoutes([]tupa.RouteInfo{routeInfo}), which we can easily access from our instantiated server.
Now at http://localhost:6969/ we will get the message “Hello world! :D “.
In Tupã, by default, every handler must receive a TupaContext and return an error. Through TupaContext, you will be able to access various functionalities to make your request successful.
Registering More Routes
To register new routes, we can simply add more paths to the routeInfo array.
Now we will have two endpoints registered, / and /cats. If we go to http://localhost:6969/cats, we will see a picture of a 🐈.
However, in a real application, we need to maintain a more organized architecture. For this, we should use Route Managers.