For our project, we need to define routes to our handlers. We will continue our project by creating a login mechanism that will validate a user and return a token to our user if successful. The following is a code block from $GOPATH/src/github.com/PacktPublishing/Echo-Essentials/chapter2/cmd/service/main.go, which shows our new route:
e.GET("/health-check", handlers.HealthCheck) // Authentication routes e.POST("/login", handlers.Login) e.POST("/logout", handlers.Logout)
Within the Echo server instance, there are helper methods to add the target path to route to a handler. In our example, we are adding a login and logout entry to the Echo server's router. Whenever a HTTP POST request with a target path of /login comes into the server, ...