twhandler

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package twhandler provides an HTTP handler that performs processing on CSS files and serves them.

Index

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) SetCache

func (h *Handler) SetCache(enabled bool)

SetCache with false will disable the cache.

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

func (h *Handler) SetMaxAge(n int)

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

func (h *Handler) SetNotFoundHandler(nfh http.Handler)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL