Documentation ¶
Overview ¶
Package twhandler provides an HTTP handler that performs processing on CSS files and serves them.
Index ¶
- type Handler
- func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (h *Handler) SetCache(enabled bool)
- func (h *Handler) SetHeaderFunc(f func(w http.ResponseWriter, r *http.Request))
- func (h *Handler) SetMaxAge(n int)
- func (h *Handler) SetNotFoundHandler(nfh http.Handler)
- func (h *Handler) SetWriteCloserFunc(f func(w http.ResponseWriter, r *http.Request) io.WriteCloser)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler serves an HTTP response for a CSS file that is process using tailwind.
func New ¶
func New(fs http.FileSystem, pathPrefix string, dist tailwind.Dist) *Handler
New returns a Handler. TODO explain args The internal cache is enabled on the Handler returned.
func NewFromFunc ¶
func NewFromFunc(fs http.FileSystem, pathPrefix string, converterFunc func(w io.Writer) *tailwind.Converter) *Handler
allows things like purger to be set
func (*Handler) ServeHTTP ¶
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler.
func (*Handler) SetHeaderFunc ¶
func (h *Handler) SetHeaderFunc(f func(w http.ResponseWriter, r *http.Request))
SetHeaderFunc assigns a function that gets called immediately before a valid response is served. It was added so applications could customize cache headers. By default, the Cache-Control header will be set to "no-cache" if it was not set earlier (causing the browser to check each time for an updated resource - which may result in a full response or a 304).
func (*Handler) SetMaxAge ¶
SetMaxAge calls SetHeaderFunc with a function that sets the Cache-Control header (if not already set) with a corresponding maximum timeout specified in seconds. If cache-breaking URLs are in use, this is a good option to set in production.
func (*Handler) SetNotFoundHandler ¶
SetNotFoundHandler assigns the handler that gets called when something is not found.
func (*Handler) SetWriteCloserFunc ¶
func (h *Handler) SetWriteCloserFunc(f func(w http.ResponseWriter, r *http.Request) io.WriteCloser)
TODO: be sure to have clear example showing brotli