Documentation
¶
Index ¶
- Constants
- func CreateRouter(handler http.Handler, cacheDir string) http.Handler
- func GetBaseTemplate(cacheSize string, filesNumber string, availableSize string, memoryUsage string, ...) string
- func GetInternalResType(url string) int
- func IsInternalUrls(url string) bool
- func RenderInternalUrls(url string, cacheDir string) (string, int)
- type PackageStruct
Constants ¶
const ( INTERNAL_PAGE_HOME string = "/" INTERNAL_PAGE_PING string = "/_/ping/" )
const ( TYPE_NOT_FOUND int = 0 TYPE_HOME int = 1 TYPE_PING int = 2 )
const LABEL_NO_VALID_VALUE = "N/A"
const SERVER_DEFAULT_TEMPLATE = `` /* 15733-byte string literal not displayed */
Variables ¶
This section is empty.
Functions ¶
func CreateRouter ¶ added in v0.7.0
CreateRouter creates an http.Handler with orthodox routing using http.ServeMux. It registers home and ping handlers, and uses the provided handler for package requests.
func GetBaseTemplate ¶
func GetInternalResType ¶
func IsInternalUrls ¶
Types ¶
type PackageStruct ¶ added in v0.7.0
type PackageStruct struct {
Handler http.Handler // The underlying HTTP handler (typically a reverse proxy)
Rules []define.Rule // Caching rules for different package types
CacheDir string // Cache directory path for statistics
}
PackageStruct is the main HTTP handler that routes requests to appropriate distribution-specific handlers and applies caching rules.
func CreatePackageStructRouter ¶ added in v0.7.0
func CreatePackageStructRouter(cacheDir string) *PackageStruct
CreatePackageStructRouter initializes and returns a new PackageStruct instance configured for the current proxy mode. It sets up URL rewriters and caching rules.
func (*PackageStruct) ServeHTTP ¶ added in v0.7.0
func (ap *PackageStruct) ServeHTTP(rw http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler interface. It processes incoming requests, matches them against caching rules, and routes them to the appropriate handler. If a matching rule is found, the request is processed with cache control headers.