Documentation
¶
Index ¶
- func ExtractOrReadBinFS(dest string, siteFS fs.FS) (http.FileSystem, map[string]string, error)
- func FS() fs.FS
- func OnlyFiles(files fs.FS) fs.FS
- func RenderOAuthAllowPage(rw http.ResponseWriter, r *http.Request, data RenderOAuthAllowData)
- func RenderStaticErrorPage(rw http.ResponseWriter, r *http.Request, data ErrorPageData)
- func ShouldCacheFile(reqFile string) bool
- type ErrorPageData
- type Handler
- type Options
- type RenderOAuthAllowData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractOrReadBinFS ¶
ExtractOrReadBinFS checks the provided fs for compressed coder binaries and extracts them into dest/bin if found. As a fallback, the provided FS is checked for a /bin directory, if it is non-empty it is returned. Finally dest/bin is returned as a fallback allowing binaries to be manually placed in dest (usually ${CODER_CACHE_DIRECTORY}/site/bin).
Returns a http.FileSystem that serves unpacked binaries, and a map of binary name to SHA1 hash. The returned hash map may be incomplete or contain hashes for missing files.
func OnlyFiles ¶ added in v2.9.0
OnlyFiles returns a new fs.FS that only contains files. If a directory is requested, os.ErrNotExist is returned. This prevents directory listings from being served.
func RenderOAuthAllowPage ¶ added in v2.9.0
func RenderOAuthAllowPage(rw http.ResponseWriter, r *http.Request, data RenderOAuthAllowData)
RenderOAuthAllowPage renders the static page for a user to "Allow" an create a new oauth2 link with an external site. This is when Coder is acting as the identity provider.
This has to be done statically because Golang has to handle the full request. It cannot defer to the FE typescript easily.
func RenderStaticErrorPage ¶
func RenderStaticErrorPage(rw http.ResponseWriter, r *http.Request, data ErrorPageData)
RenderStaticErrorPage renders the static error page. This is used by app requests to avoid dependence on the dashboard but maintain the ability to render a friendly error page on subdomains.
func ShouldCacheFile ¶
Types ¶
type ErrorPageData ¶
type ErrorPageData struct {
Status int
// HideStatus will remove the status code from the page.
HideStatus bool
Title string
Description string
RetryEnabled bool
DashboardURL string
Warnings []string
AdditionalInfo string
AdditionalButtonLink string
AdditionalButtonText string
RenderDescriptionMarkdown bool
}
ErrorPageData contains the variables that are found in site/static/error.html.
type Handler ¶
type Handler struct {
// RegionsFetcher will attempt to fetch the more detailed WorkspaceProxy data, but will fall back to the
// regions if the user does not have the correct permissions.
RegionsFetcher func(ctx context.Context) (any, error)
Entitlements *entitlements.Set
Experiments atomic.Pointer[codersdk.Experiments]
// contains filtered or unexported fields
}
type Options ¶
type Options struct {
BinFS http.FileSystem
BinHashes map[string]string
Database database.Store
SiteFS fs.FS
OAuth2Configs *httpmw.OAuth2Configs
DocsURL string
BuildInfo codersdk.BuildInfoResponse
AppearanceFetcher *atomic.Pointer[appearance.Fetcher]
Entitlements *entitlements.Set
Telemetry telemetry.Reporter
Logger slog.Logger
}