mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-08 13:52:53 +02:00
httputil: remove retry button (#1438)
Signed-off-by: Bobby DeSimone <bobbydesimone@gmail.com>
This commit is contained in:
parent
a1ba04d231
commit
0c60a9404e
2 changed files with 13 additions and 31 deletions
|
@ -28,12 +28,6 @@
|
||||||
them with your
|
them with your
|
||||||
<a href="/.pomerium/">request details</a>.
|
<a href="/.pomerium/">request details</a>.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{end}} {{if.RetryURL}}
|
|
||||||
<div class="message">
|
|
||||||
If you believe the error is temporary, you can
|
|
||||||
<a href="{{.RetryURL}}">retry</a> the request.
|
|
||||||
</div>
|
|
||||||
{{end}}
|
{{end}}
|
||||||
</section>
|
</section>
|
||||||
<div class="card-footer">
|
<div class="card-footer">
|
||||||
|
@ -44,7 +38,6 @@
|
||||||
class="icon"
|
class="icon"
|
||||||
/>
|
/>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<div class="text-right text-muted small">
|
<div class="text-right text-muted small">
|
||||||
{{.RequestID}} <br />
|
{{.RequestID}} <br />
|
||||||
Pomerium {{.Version}}
|
Pomerium {{.Version}}
|
||||||
|
|
|
@ -8,7 +8,6 @@ import (
|
||||||
"github.com/pomerium/pomerium/internal/frontend"
|
"github.com/pomerium/pomerium/internal/frontend"
|
||||||
"github.com/pomerium/pomerium/internal/log"
|
"github.com/pomerium/pomerium/internal/log"
|
||||||
"github.com/pomerium/pomerium/internal/telemetry/requestid"
|
"github.com/pomerium/pomerium/internal/telemetry/requestid"
|
||||||
"github.com/pomerium/pomerium/internal/urlutil"
|
|
||||||
"github.com/pomerium/pomerium/internal/version"
|
"github.com/pomerium/pomerium/internal/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -41,22 +40,6 @@ func (e *HTTPError) Debugable() bool {
|
||||||
return e.Status == http.StatusUnauthorized || e.Status == http.StatusForbidden
|
return e.Status == http.StatusUnauthorized || e.Status == http.StatusForbidden
|
||||||
}
|
}
|
||||||
|
|
||||||
// RetryURL returns the requests intended destination, if any.
|
|
||||||
func (e *HTTPError) RetryURL(r *http.Request) string {
|
|
||||||
return r.FormValue(urlutil.QueryRedirectURI)
|
|
||||||
}
|
|
||||||
|
|
||||||
type errResponse struct {
|
|
||||||
Status int
|
|
||||||
Error string
|
|
||||||
|
|
||||||
StatusText string `json:"-"`
|
|
||||||
RequestID string `json:",omitempty"`
|
|
||||||
CanDebug bool `json:"-"`
|
|
||||||
RetryURL string `json:"-"`
|
|
||||||
Version string `json:"-"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// ErrorResponse replies to the request with the specified error message and HTTP code.
|
// ErrorResponse replies to the request with the specified error message and HTTP code.
|
||||||
// It does not otherwise end the request; the caller should ensure no further
|
// It does not otherwise end the request; the caller should ensure no further
|
||||||
// writes are done to w.
|
// writes are done to w.
|
||||||
|
@ -67,24 +50,30 @@ func (e *HTTPError) ErrorResponse(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
log.FromRequest(r).Info().Err(e).Msg("httputil: ErrorResponse")
|
log.FromRequest(r).Info().Err(e).Msg("httputil: ErrorResponse")
|
||||||
requestID := requestid.FromContext(r.Context())
|
requestID := requestid.FromContext(r.Context())
|
||||||
response := errResponse{
|
|
||||||
|
response := struct {
|
||||||
|
Status int
|
||||||
|
Error string
|
||||||
|
StatusText string `json:"-"`
|
||||||
|
RequestID string `json:",omitempty"`
|
||||||
|
CanDebug bool `json:"-"`
|
||||||
|
Version string `json:"-"`
|
||||||
|
}{
|
||||||
Status: e.Status,
|
Status: e.Status,
|
||||||
StatusText: http.StatusText(e.Status),
|
StatusText: http.StatusText(e.Status),
|
||||||
Error: e.Error(),
|
Error: e.Error(),
|
||||||
RequestID: requestID,
|
RequestID: requestID,
|
||||||
CanDebug: e.Debugable(),
|
CanDebug: e.Debugable(),
|
||||||
RetryURL: e.RetryURL(r),
|
|
||||||
Version: fullVersion,
|
Version: fullVersion,
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.Header.Get("Accept") == "application/json" {
|
if r.Header.Get("Accept") == "application/json" {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
err := json.NewEncoder(w).Encode(response)
|
if err := json.NewEncoder(w).Encode(response); err != nil {
|
||||||
if err != nil {
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
} else {
|
return
|
||||||
|
}
|
||||||
w.Header().Set("Content-Type", "text/html; charset=UTF-8")
|
w.Header().Set("Content-Type", "text/html; charset=UTF-8")
|
||||||
errorTemplate.ExecuteTemplate(w, "error.html", response)
|
errorTemplate.ExecuteTemplate(w, "error.html", response)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue