func latencyMiddleware() echo.MiddlewareFunc {
	return func(next echo.HandlerFunc) echo.HandlerFunc {
		return func(c echo.Context) error {
			startTime := time.Now()
			c.Set("startTime", startTime)
			return next(c)
		}
	}
}
latencyMiddleware sets the start time in the echo.Context under "startTime".
Its value will be used later to calculate a request latency.

startTime := c.Get("startTime").(time.Time)
package api
import (
	"context"
	"errors"
	"fmt"
	"net/http"
	"time"
	"github.com/google/uuid"
	"github.com/labstack/echo/v4"
	"go.uber.org/zap"
)
var ErrAsyncProcess = errors.New("async process")
func ParseError(err error) (int, string) {
	echoErr, ok := err.(*echo.HTTPError)
	if ok {
		return echoErr.Code, http.StatusText(echoErr.Code)
	}
	if errors.Is(err, context.DeadlineExceeded) {
		return http.StatusServiceUnavailable, http.StatusText(http.StatusServiceUnavailable)
	}
	var httpErr HTTPError
	if errors.As(err, &httpErr) {
		return httpErr.HTTPError()
	}
	return http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError)
}
func httpErrorHandler() echo.HTTPErrorHandler {
	return func(err error, c echo.Context) {
		logger := c.Get("logger").(*zap.Logger)
		status, message := ParseError(err)
		c.Response().Header().Add(echo.HeaderContentType, echo.MIMETextPlainCharsetUTF8)
		err = c.String(status, message)
		if err != nil {
			logger.Error(fmt.Sprintf("send error response: %s", err.Error()))
		}
	}
}