Documentation
¶
Index ¶
- Constants
- Variables
- func App(opt ...AppOption) func(http.ResponseWriter, *http.Request, fs.FS, ...Option) (*Info, error)
- func AutoCert(email string, host string) *tls.Config
- func Error(w http.ResponseWriter, err error)
- func ErrorStatusCode(err error) int
- func Handle(w http.ResponseWriter, r *http.Request, fn func() (*Info, error))
- func Listen(h http.Handler, opt ...ListenOption)
- func NewAppHandler(fsys fs.FS, opt ...AppOption) http.Handler
- func TLS(h http.Handler, hostPolicy HostPolicy) error
- type AppOption
- type HostPolicy
- type Info
- func Blob(w http.ResponseWriter, r *http.Request, b blob.Blob, opt ...Option) (*Info, error)
- func Header(w http.ResponseWriter, opt ...Option) (*Info, error)
- func JSON(w http.ResponseWriter, r *http.Request, v any, opt ...Option) (*Info, error)
- func Reader(rw http.ResponseWriter, r *http.Request, rd io.Reader, opt ...Option) (*Info, error)
- func Redirect(w http.ResponseWriter, r *http.Request, url string, status int) (*Info, error)
- func SSE[T any](w http.ResponseWriter, r *http.Request, iter iter.Seq[T], ...) (*Info, error)
- type ListenOption
- type Option
- func Attachment(name string) Option
- func Compress(b bool) Option
- func ContentLength(n int64) Option
- func ContentType(ct string) Option
- func ContentTypeFromPath(p string) Option
- func Immutable(b bool) Option
- func LastModified(t time.Time) Option
- func Location(loc string) Option
- func MaxAge(d time.Duration) Option
- func NoOp() Option
- func Range(start, end int64) Option
- func StatusCode(n int) Option
- type SSEEvent
- type StatusCoder
Constants ¶
View Source
const ( DefaultReadTimeout = time.Second * 30 DefaultWriteTimeout = time.Second * 60 DefaultIdleTimeout = time.Second * 120 DefaultAddr = ":http" DefaultTLSAddr = ":https" )
View Source
const DefaultIndexFile = "index.html"
Variables ¶
View Source
var ErrContentLengthMismatch = errors.New("content-length mismatch")
Functions ¶
func Error ¶
func Error(w http.ResponseWriter, err error)
func ErrorStatusCode ¶
func Listen ¶
func Listen(h http.Handler, opt ...ListenOption)
Types ¶
type HostPolicy ¶
type HostPolicy = autocert.HostPolicy
func HostSuffix ¶
func HostSuffix(suffix string) HostPolicy
func HostWhitelist ¶
func HostWhitelist(hosts ...string) HostPolicy
type Info ¶
type Info struct {
StatusCode int
ContentLength int64
ContentType string
Location string
LastModified time.Time
MaxAge time.Duration
Immutable bool
Compress bool
Disposition string
Range *[2]int64
}
type ListenOption ¶
type ListenOption func(*listenConfig)
func Addr ¶
func Addr(addr string) ListenOption
type Option ¶
type Option func(c *config)
func Attachment ¶
func ContentLength ¶
func ContentType ¶
func ContentTypeFromPath ¶
func LastModified ¶
func StatusCode ¶
type StatusCoder ¶
type StatusCoder interface {
StatusCode() int
}
Click to show internal directories.
Click to hide internal directories.