Basic Concept of Echo

Context

Context represents the context of the current HTTP request. It holds request and response objects, path, path parameters, data and registered handler.

Route

Route is used to handle the request of a specific request.

contains a handler and information for matching against requests.

e.GET("/", helloHandler) // registers a new GET route for a path with matching handler in the router

Handler Func

defines a function to serve HTTP requests.

HandlerFunc func(Context) error
// helloHandler is to serve get request of `/`
func helloHandler(ctx echo.Context) error {
	return ctx.String(http.StatusOK, "Hello From Echo!")
}

Middleware

Apply a handler to a group of requests.

middleware type

MiddlewareFunc func(HandlerFunc) HandlerFunc

Use log middleware

e.Use(middleware.Logger()) // log middleware

Request

req := ctx.Request() // get *http.Request