WriteWorkspaceAppOffline writes a HTML 404 error page for a workspace app. If appReq is not nil, it will be used to log the request details at debug level.
(log slog.Logger, accessURL *url.URL, rw http.ResponseWriter, r *http.Request, appReq *Request, msg string)
| 80 | // WriteWorkspaceAppOffline writes a HTML 404 error page for a workspace app. If |
| 81 | // appReq is not nil, it will be used to log the request details at debug level. |
| 82 | func WriteWorkspaceAppOffline(log slog.Logger, accessURL *url.URL, rw http.ResponseWriter, r *http.Request, appReq *Request, msg string) { |
| 83 | if appReq != nil { |
| 84 | slog.Helper() |
| 85 | log.Debug(r.Context(), |
| 86 | "workspace app unavailable: "+msg, |
| 87 | slog.F("username_or_id", appReq.UsernameOrID), |
| 88 | slog.F("workspace_and_agent", appReq.WorkspaceAndAgent), |
| 89 | slog.F("workspace_name_or_id", appReq.WorkspaceNameOrID), |
| 90 | slog.F("agent_name_or_id", appReq.AgentNameOrID), |
| 91 | slog.F("app_slug_or_port", appReq.AppSlugOrPort), |
| 92 | slog.F("hostname_prefix", appReq.Prefix), |
| 93 | ) |
| 94 | } |
| 95 | |
| 96 | site.RenderStaticErrorPage(rw, r, site.ErrorPageData{ |
| 97 | Status: http.StatusNotFound, |
| 98 | Title: "Application Unavailable", |
| 99 | Description: msg, |
| 100 | Actions: []site.Action{ |
| 101 | { |
| 102 | Text: "Retry", |
| 103 | }, |
| 104 | { |
| 105 | URL: accessURL.String(), |
| 106 | Text: "Back to site", |
| 107 | }, |
| 108 | }, |
| 109 | }) |
| 110 | } |
| 111 | |
| 112 | // WriteWorkspaceOffline writes a HTML 400 error page for a workspace app. If |
| 113 | // appReq is not nil, it will be used to log the request details at debug level. |
no test coverage detected