site

package
v2.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2024 License: AGPL-3.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractOrReadBinFS

func ExtractOrReadBinFS(dest string, siteFS fs.FS) (http.FileSystem, map[string]string, error)

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 FS

func FS() fs.FS

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

func ShouldCacheFile(reqFile string) bool

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

	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 atomic.Pointer[codersdk.Entitlements]
	Experiments  atomic.Pointer[codersdk.Experiments]
	// contains filtered or unexported fields
}

func New

func New(opts *Options) *Handler

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(rw http.ResponseWriter, r *http.Request)

type Options

type Options struct {
	BinFS             http.FileSystem
	BinHashes         map[string]string
	Database          database.Store
	SiteFS            fs.FS
	OAuth2Configs     *httpmw.OAuth2Configs
	DocsURL           string
	AppearanceFetcher *atomic.Pointer[appearance.Fetcher]
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL