func()

in cmd/interceptor/main.go [160:184]


func (h *edpInterceptorHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	b, err := h.EDPInterceptor.Execute(r)

	if err != nil {
		interceptorErr := &interceptor.HTTPError{}

		if errors.As(err, interceptorErr) {
			h.Logger.Infof("HTTP %d - %s", interceptorErr.Status(), interceptorErr)
			http.Error(w, interceptorErr.Error(), interceptorErr.Status())

			return
		}

		h.Logger.Errorf("Non Status Error: %s", err)
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)

		return
	}

	w.Header().Add("Content-Type", "application/json")

	if _, err := w.Write(b); err != nil {
		h.Logger.Errorf("Failed to write response: %s", err)
	}
}