Check out cube middleware for HTTP analytics, monitoring and alerting. Measure server latency, data transfer, discover top endpoints, server errors and much more.


echo.Context represents the context of the current HTTP request. It holds request and response reference, path, path parameters, data, registered handler and APIs to read request and write response. As Context is an interface, it is easy to extend it with custom APIs.

Extending Context

Define a custom context

type CustomContext struct {

func (c *CustomContext) Foo() {

func (c *CustomContext) Bar() {

Create a middleware to extend default context

e.Use(func(h echo.HandlerFunc) echo.HandlerFunc {
	return func(c echo.Context) error {
		cc := &CustomContext{c}
		return h(cc)

This middleware should be registered before any other middleware.

Use in handler

e.GET("/", func(c echo.Context) error {
	cc := c.(*CustomContext)
	return cc.String(200, "OK")

Got a question?