-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
file_server: support precompressed files
- Loading branch information
Showing
9 changed files
with
206 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package caddybr | ||
|
||
import ( | ||
"github.com/caddyserver/caddy/v2" | ||
"github.com/caddyserver/caddy/v2/modules/caddyhttp/encode" | ||
) | ||
|
||
func init() { | ||
caddy.RegisterModule(BrotliPrecompressed{}) | ||
} | ||
|
||
// BrotliPrecompressed provides the file extension for files precompressed with brotli encoding | ||
type BrotliPrecompressed struct{} | ||
|
||
// CaddyModule returns the Caddy module information. | ||
func (BrotliPrecompressed) CaddyModule() caddy.ModuleInfo { | ||
return caddy.ModuleInfo{ | ||
ID: "http.precompressed.br", | ||
New: func() caddy.Module { return new(BrotliPrecompressed) }, | ||
} | ||
} | ||
|
||
// AcceptEncoding returns the name of the encoding as | ||
// used in the Accept-Encoding request headers. | ||
func (BrotliPrecompressed) AcceptEncoding() string { return "br" } | ||
|
||
// Suffix returns the filename suffix of precomressed files | ||
func (BrotliPrecompressed) Suffix() string { return "br" } | ||
|
||
// Interface guards | ||
var _ encode.Precompressed = (*BrotliPrecompressed)(nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package caddygzip | ||
|
||
import ( | ||
"github.com/caddyserver/caddy/v2" | ||
"github.com/caddyserver/caddy/v2/modules/caddyhttp/encode" | ||
) | ||
|
||
func init() { | ||
caddy.RegisterModule(GzipPrecompressed{}) | ||
} | ||
|
||
// GzipPrecompressed provides the file extension for files precompressed with gzip encoding | ||
type GzipPrecompressed struct { | ||
Gzip | ||
} | ||
|
||
// CaddyModule returns the Caddy module information. | ||
func (GzipPrecompressed) CaddyModule() caddy.ModuleInfo { | ||
return caddy.ModuleInfo{ | ||
ID: "http.precompressed.gzip", | ||
New: func() caddy.Module { return new(GzipPrecompressed) }, | ||
} | ||
} | ||
|
||
// Suffix returns the filename suffix of precomressed files | ||
func (GzipPrecompressed) Suffix() string { return "gz" } | ||
|
||
// Interface guards | ||
var _ encode.Precompressed = (*GzipPrecompressed)(nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package caddyzstd | ||
|
||
import ( | ||
"github.com/caddyserver/caddy/v2" | ||
"github.com/caddyserver/caddy/v2/modules/caddyhttp/encode" | ||
) | ||
|
||
func init() { | ||
caddy.RegisterModule(ZstdPrecompressed{}) | ||
} | ||
|
||
// ZstdPrecompressed provides the file extension for files precompressed with zstandard encoding | ||
type ZstdPrecompressed struct { | ||
Zstd | ||
} | ||
|
||
// CaddyModule returns the Caddy module information. | ||
func (ZstdPrecompressed) CaddyModule() caddy.ModuleInfo { | ||
return caddy.ModuleInfo{ | ||
ID: "http.precompressed.zstd", | ||
New: func() caddy.Module { return new(ZstdPrecompressed) }, | ||
} | ||
} | ||
|
||
// Suffix returns the filename suffix of precomressed files | ||
func (ZstdPrecompressed) Suffix() string { return "zst" } | ||
|
||
// Interface guards | ||
var _ encode.Precompressed = (*ZstdPrecompressed)(nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters