{"modulePath":"github.com/bitechdev/ResolveSpec","version":"v1.3.14","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package policies\n\n## Types\n\n```go\ntype ConfigurableMIMEResolver struct {\n\t// contains filtered or unexported fields\n}\n```\nConfigurableMIMEResolver implements a MIME type resolver with user-defined mappings only. It does not use any default mappings.\n\n```go\nfunc NewConfigurableMIMEResolver(types map[string]string) *ConfigurableMIMEResolver\n```\nNewConfigurableMIMEResolver creates a new ConfigurableMIMEResolver with the given mappings.\n\n```go\nfunc (r *ConfigurableMIMEResolver) GetMIMEType(filePath string) string\n```\nGetMIMEType returns the MIME type for the given file path.\n\n```go\nfunc (r *ConfigurableMIMEResolver) RegisterMIMEType(extension, mimeType string)\n```\nRegisterMIMEType registers a MIME type for the given file extension.\n\n```go\ntype DefaultMIMEResolver struct {\n\t// contains filtered or unexported fields\n}\n```\nDefaultMIMEResolver implements a MIME type resolver using Go's standard mime package and a set of common web file type mappings.\n\n```go\nfunc NewDefaultMIMEResolver() *DefaultMIMEResolver\n```\nNewDefaultMIMEResolver creates a new DefaultMIMEResolver with common web MIME types.\n\n```go\nfunc (r *DefaultMIMEResolver) GetMIMEType(filePath string) string\n```\nGetMIMEType returns the MIME type for the given file path. It first checks custom registered types, then falls back to Go's mime.TypeByExtension.\n\n```go\nfunc (r *DefaultMIMEResolver) RegisterMIMEType(extension, mimeType string)\n```\nRegisterMIMEType registers a custom MIME type for the given file extension.\n\n```go\ntype ExtensionBasedCachePolicy struct {\n\t// contains filtered or unexported fields\n}\n```\nExtensionBasedCachePolicy implements a cache policy that varies by file extension.\n\n```go\nfunc NewExtensionBasedCachePolicy(rules map[string]int, defaultTime int) *ExtensionBasedCachePolicy\n```\nNewExtensionBasedCachePolicy creates a new ExtensionBasedCachePolicy. rules maps file extensions (with leading dot, e.g., \".js\") to cache times in seconds. defaultTime is used for files that don't match any rule.\n\n```go\nfunc (p *ExtensionBasedCachePolicy) GetCacheHeaders(filePath string) map[string]string\n```\nGetCacheHeaders returns cache headers based on the file extension.\n\n```go\nfunc (p *ExtensionBasedCachePolicy) GetCacheTime(filePath string) int\n```\nGetCacheTime returns the cache duration based on the file extension.\n\n```go\ntype ExtensionBasedFallback struct {\n\t// contains filtered or unexported fields\n}\n```\nExtensionBasedFallback implements a fallback strategy that skips fallback for known static file extensions. This is the behavior from the original StaticHTMLFallbackHandler.\n\n```go\nfunc NewDefaultExtensionBasedFallback(fallbackPath string) *ExtensionBasedFallback\n```\nNewDefaultExtensionBasedFallback creates an ExtensionBasedFallback with common web asset extensions. This matches the behavior of the original StaticHTMLFallbackHandler.\n\n```go\nfunc NewExtensionBasedFallback(staticExtensions []string, fallbackPath string) *ExtensionBasedFallback\n```\nNewExtensionBasedFallback creates a new ExtensionBasedFallback strategy. staticExtensions is a list of file extensions (with leading dot) that should NOT use fallback. fallbackPath is the file to serve when fallback is triggered.\n\n```go\nfunc (f *ExtensionBasedFallback) GetFallbackPath(filePath string) string\n```\nGetFallbackPath returns the configured fallback path.\n\n```go\nfunc (f *ExtensionBasedFallback) ShouldFallback(filePath string) bool\n```\nShouldFallback returns true if the file path doesn't have a static asset extension.\n\n```go\ntype HTMLExtensionFallback struct {\n\t// contains filtered or unexported fields\n}\n```\nHTMLExtensionFallback implements a fallback strategy that appends .html to paths. This tries to serve {path}.html for missing files.\n\n```go\nfunc NewHTMLExtensionFallback(staticExtensions []string) *HTMLExtensionFallback\n```\nNewHTMLExtensionFallback creates a new HTMLExtensionFallback strategy.\n\n```go\nfunc (f *HTMLExtensionFallback) GetFallbackPath(filePath string) string\n```\nGetFallbackPath returns the path with .html appended.\n\n```go\nfunc (f *HTMLExtensionFallback) ShouldFallback(filePath string) bool\n```\nShouldFallback returns true if the path doesn't have a static extension or .html.\n\n```go\ntype HTMLFallbackStrategy struct {\n\t// contains filtered or unexported fields\n}\n```\nHTMLFallbackStrategy implements a fallback strategy for Single Page Applications (SPAs). It serves a specified HTML file (typically index.html) for non-file requests.\n\n```go\nfunc NewHTMLFallbackStrategy(indexFile string) *HTMLFallbackStrategy\n```\nNewHTMLFallbackStrategy creates a new HTMLFallbackStrategy. indexFile is the path to the HTML file to serve (e.g., \"index.html\", \"/index.html\").\n\n```go\nfunc (f *HTMLFallbackStrategy) GetFallbackPath(filePath string) string\n```\nGetFallbackPath returns the index file path.\n\n```go\nfunc (f *HTMLFallbackStrategy) ShouldFallback(filePath string) bool\n```\nShouldFallback returns true for requests that don't look like static assets.\n\n```go\ntype NoCachePolicy struct{}\n```\nNoCachePolicy implements a cache policy that disables all caching.\n\n```go\nfunc NewNoCachePolicy() *NoCachePolicy\n```\nNewNoCachePolicy creates a new NoCachePolicy.\n\n```go\nfunc (p *NoCachePolicy) GetCacheHeaders(filePath string) map[string]string\n```\nGetCacheHeaders returns headers that disable caching.\n\n```go\nfunc (p *NoCachePolicy) GetCacheTime(filePath string) int\n```\nGetCacheTime always returns 0 (no caching).\n\n```go\ntype NoFallback struct{}\n```\nNoFallback implements a fallback strategy that never falls back. All requests for missing files will result in 404 responses.\n\n```go\nfunc NewNoFallback() *NoFallback\n```\nNewNoFallback creates a new NoFallback strategy.\n\n```go\nfunc (f *NoFallback) GetFallbackPath(filePath string) string\n```\nGetFallbackPath returns an empty string (never called since ShouldFallback returns false).\n\n```go\nfunc (f *NoFallback) ShouldFallback(filePath string) bool\n```\nShouldFallback always returns false.\n\n```go\ntype SimpleCachePolicy struct {\n\t// contains filtered or unexported fields\n}\n```\nSimpleCachePolicy implements a basic cache policy with a single TTL for all files.\n\n```go\nfunc NewSimpleCachePolicy(cacheTimeSeconds int) *SimpleCachePolicy\n```\nNewSimpleCachePolicy creates a new SimpleCachePolicy with the given cache time in seconds.\n\n```go\nfunc (p *SimpleCachePolicy) GetCacheHeaders(filePath string) map[string]string\n```\nGetCacheHeaders returns the Cache-Control header for the given file.\n\n```go\nfunc (p *SimpleCachePolicy) GetCacheTime(filePath string) int\n```\nGetCacheTime returns the cache duration for any file.\n\n","path":"github.com/bitechdev/ResolveSpec/pkg/server/staticweb/policies","name":"policies","synopsis":"","isRedistributable":true}
