Adding routes

The Echo instance's Add method allows the user to insert a new route into the router. The parameters include two string arguments, method and path, as well as an echo.HandlerFunc variable for which the resulting request routing match should map. Finally, a list of applicable middleware functions to apply to the processing pipeline is the last parameter. The Add method declaration can be seen as follows:

func (e *Echo) Add(method, path string, handler HandlerFunc, middleware ...MiddlewareFunc) *Route {

Though there is no input validation for the method parameter within Echo RFC 7231, Section 4.3 defines allowable request methods that are acceptable. Moreover, the handler will not be mapped unless the HTTP method is one of the ...

Get Echo Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.