web

package
v0.0.0-...-2b8ec9a Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2023 License: Apache-2.0 Imports: 26 Imported by: 1

Documentation

Index

Constants

View Source
const AppAssetsURLDirname = "static"
View Source
const GeneratedAssetsURLDirname = "shared-assets"

Variables

View Source
View Source
var AppLogoDark = resource.RegisterResource(ImageDescriptor{Name: "app_logo_dark"})
View Source
var AuthgearDarkThemeCSS = resource.RegisterResource(CSSDescriptor{
	Path: path.Join(AppAssetsURLDirname, "authgear-dark-theme.css"),
})
View Source
var AuthgearLightThemeCSS = resource.RegisterResource(CSSDescriptor{
	Path: path.Join(AppAssetsURLDirname, "authgear-light-theme.css"),
})
View Source
var DependencySet = wire.NewSet(
	wire.Struct(new(StaticAssetResolver), "*"),
)
View Source
var Favicon = resource.RegisterResource(ImageDescriptor{Name: "favicon"})
View Source
var StaticAssetResources = map[string]resource.Descriptor{
	"app-logo":      AppLogo,
	"app-logo-dark": AppLogoDark,
	"favicon":       Favicon,

	"authgear-light-theme.css": AuthgearLightThemeCSS,
	"authgear-dark-theme.css":  AuthgearDarkThemeCSS,
}
View Source
var UnsupportedImageFile = apierrors.BadRequest.WithReason("UnsupportedImageFile")

Functions

func CSPDirectives

func CSPDirectives(publicOrigin string, nonce string, cdnHost string, allowInlineScript bool) ([]string, error)

func GetCSPNonce

func GetCSPNonce(ctx context.Context) string

func GetHashedName

func GetHashedName(file string) string

func LookLikeAHash

func LookLikeAHash(s string) bool

func WithCSPNonce

func WithCSPNonce(ctx context.Context, nonce string) context.Context

Types

type CSSDescriptor

type CSSDescriptor struct {
	Path string
}

func (CSSDescriptor) FindResources

func (d CSSDescriptor) FindResources(fs resource.Fs) ([]resource.Location, error)

func (CSSDescriptor) MatchResource

func (d CSSDescriptor) MatchResource(path string) (*resource.Match, bool)

func (CSSDescriptor) UpdateResource

func (d CSSDescriptor) UpdateResource(_ context.Context, _ []resource.ResourceFile, resrc *resource.ResourceFile, data []byte) (*resource.ResourceFile, error)

func (CSSDescriptor) ViewResources

func (d CSSDescriptor) ViewResources(resources []resource.ResourceFile, rawView resource.View) (interface{}, error)

type EmbeddedResourceManager

type EmbeddedResourceManager interface {
	AssetName(key string) (name string, err error)
}

type GlobalEmbeddedResourceManager

type GlobalEmbeddedResourceManager struct {
	Manifest *Manifest
	// contains filtered or unexported fields
}

func NewDefaultGlobalEmbeddedResourceManager

func NewDefaultGlobalEmbeddedResourceManager() (*GlobalEmbeddedResourceManager, error)

func NewGlobalEmbeddedResourceManager

func NewGlobalEmbeddedResourceManager(manifest *Manifest) (*GlobalEmbeddedResourceManager, error)

func (*GlobalEmbeddedResourceManager) AssetName

func (m *GlobalEmbeddedResourceManager) AssetName(key string) (name string, err error)

func (*GlobalEmbeddedResourceManager) Close

func (*GlobalEmbeddedResourceManager) GetManifestContext

func (m *GlobalEmbeddedResourceManager) GetManifestContext() *ManifestContext

func (*GlobalEmbeddedResourceManager) ManifestFilePath

func (m *GlobalEmbeddedResourceManager) ManifestFilePath() string

func (*GlobalEmbeddedResourceManager) Open

type ImageDescriptor

type ImageDescriptor struct {
	Name string
}

func (ImageDescriptor) FindResources

func (a ImageDescriptor) FindResources(fs resource.Fs) ([]resource.Location, error)

func (ImageDescriptor) MatchResource

func (a ImageDescriptor) MatchResource(path string) (*resource.Match, bool)

func (ImageDescriptor) UpdateResource

func (ImageDescriptor) ViewResources

func (a ImageDescriptor) ViewResources(resources []resource.ResourceFile, rawView resource.View) (interface{}, error)

type JavaScriptDescriptor

type JavaScriptDescriptor struct {
	Path string
}

func (JavaScriptDescriptor) FindResources

func (d JavaScriptDescriptor) FindResources(fs resource.Fs) ([]resource.Location, error)

func (JavaScriptDescriptor) MatchResource

func (d JavaScriptDescriptor) MatchResource(path string) (*resource.Match, bool)

func (JavaScriptDescriptor) UpdateResource

func (JavaScriptDescriptor) ViewResources

func (d JavaScriptDescriptor) ViewResources(resources []resource.ResourceFile, rawView resource.View) (interface{}, error)

type Manifest

type Manifest struct {
	ResourceDir string
	Name        string
	// contains filtered or unexported fields
}

type ManifestContext

type ManifestContext struct {
	Content map[string]string
}

type ResourceManager

type ResourceManager interface {
	Read(desc resource.Descriptor, view resource.View) (interface{}, error)
}

type StaticAsset

type StaticAsset struct {
	Path string
	Data []byte
}

type StaticAssetResolver

type StaticAssetResolver struct {
	Context           context.Context
	Config            *config.HTTPConfig
	Localization      *config.LocalizationConfig
	HTTPProto         httputil.HTTPProto
	WebAppCDNHost     config.WebAppCDNHost
	Resources         ResourceManager
	EmbeddedResources EmbeddedResourceManager
}

func (*StaticAssetResolver) GeneratedStaticAssetURL

func (r *StaticAssetResolver) GeneratedStaticAssetURL(key string) (string, error)

func (*StaticAssetResolver) HasAppSpecificAsset

func (r *StaticAssetResolver) HasAppSpecificAsset(id string) bool

func (*StaticAssetResolver) StaticAssetURL

func (r *StaticAssetResolver) StaticAssetURL(id string) (string, error)

Jump to

Keyboard shortcuts

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