site

package
v2.10.2 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: AGPL-3.0 Imports: 40 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 OnlyFiles added in v2.9.0

func OnlyFiles(files fs.FS) fs.FS

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

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]
}

type RenderOAuthAllowData added in v2.9.0

type RenderOAuthAllowData struct {
	AppIcon     string
	AppName     string
	CancelURI   string
	RedirectURI string
	Username    string
}

RenderOAuthAllowData contains the variables that are found in site/static/oauth2allow.html.

Jump to

Keyboard shortcuts

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