The new handler function type

Prior to Go 1., the request data structure in the standard library did not include any form of modifiable context structure. Due to this limitation in the standard library, it makes sense that many frameworks decided that the standard library definition of what a handler did not offer needed flexibility. That being the case, these frameworks developed their own concepts of context, and changed their handler function type to pass in a context instead. In the following snippet, you can see the differences between these handler types, where the Echo handler function type has a context parameter, while the standard library does not:

type HandlerFunc func(ResponseWriter, *Request) // http handler function type type ...

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.