Documentation
¶
Overview ¶
Package etagcache is an Ambient plugin that provides caching using etag.
Index ¶
- Constants
- type CustomResponseWriter
- type Plugin
- func (p *Plugin) GrantRequests() []ambient.GrantRequest
- func (p *Plugin) Handler(next http.Handler) http.Handler
- func (p *Plugin) Middleware() []func(next http.Handler) http.Handler
- func (p *Plugin) PluginName() string
- func (p *Plugin) PluginVersion() string
- func (p *Plugin) Settings() []ambient.Setting
Examples ¶
Constants ¶
View Source
const (
// MaxAge allows user to set MaxAge in seconds.
MaxAge = "MaxAge"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CustomResponseWriter ¶
type CustomResponseWriter struct {
// contains filtered or unexported fields
}
CustomResponseWriter can be used
func NewCustomResponseWriter ¶
func NewCustomResponseWriter() *CustomResponseWriter
NewCustomResponseWriter stores the response without writing it.
func (*CustomResponseWriter) Header ¶
func (w *CustomResponseWriter) Header() http.Header
Header return custom header.
func (*CustomResponseWriter) Write ¶
func (w *CustomResponseWriter) Write(b []byte) (int, error)
Write to the custom body.
func (*CustomResponseWriter) WriteHeader ¶
func (w *CustomResponseWriter) WriteHeader(statusCode int)
WriteHeader will write to the custom status code.
func (*CustomResponseWriter) WriteTo ¶
func (w *CustomResponseWriter) WriteTo(wr http.ResponseWriter)
WriteTo will write to the response writer.
type Plugin ¶
type Plugin struct {
*ambient.PluginBase
}
Plugin represents an Ambient plugin.
func New ¶
func New() *Plugin
New returns an Ambient plugin that provides gzip content compression midddleware.
Example ¶
package main
import (
"log"
"github.com/ambientkit/ambient"
"github.com/ambientkit/ambient/pkg/ambientapp"
"github.com/ambientkit/plugin/logger/zaplogger"
"github.com/ambientkit/plugin/middleware/etagcache"
"github.com/ambientkit/plugin/storage/memorystorage"
)
func main() {
plugins := &ambient.PluginLoader{
// Core plugins are implicitly trusted.
Router: nil,
TemplateEngine: nil,
SessionManager: nil,
// Trusted plugins are those that are typically needed to boot so they
// will be enabled and given full access.
TrustedPlugins: map[string]bool{},
Plugins: []ambient.Plugin{},
Middleware: []ambient.MiddlewarePlugin{
// Middleware - executes top to bottom.
etagcache.New(),
},
}
_, _, err := ambientapp.NewApp("myapp", "1.0",
zaplogger.New(),
ambient.StoragePluginGroup{
Storage: memorystorage.New(),
},
plugins)
if err != nil {
log.Fatalln(err.Error())
}
}
func (*Plugin) GrantRequests ¶
func (p *Plugin) GrantRequests() []ambient.GrantRequest
GrantRequests returns a list of grants requested by the plugin.
func (*Plugin) Middleware ¶
Middleware returns router middleware.
func (*Plugin) PluginName ¶
PluginName returns the plugin name.
func (*Plugin) PluginVersion ¶
PluginVersion returns the plugin version.
Click to show internal directories.
Click to hide internal directories.