package httputil

import "git.sr.ht/~sircmpwn/gddo/internal/httputil"

Package httputil provides HTTP utility functions.

Index

Types

type FileServer

type FileServer struct {
	// contains filtered or unexported fields
}

FileServer serves static files.

func NewFileServer

func NewFileServer(fsys fs.FS) *FileServer

NewFileServer returns a new FileServer which serves files from the given filesystem.

func (*FileServer) FileHandler

func (s *FileServer) FileHandler(filename string) http.Handler

FileHandler returns a handler that serves a single file. The file is specified by a slash separated path relative to the static server's filesystem.

func (*FileServer) QueryParam

func (s *FileServer) QueryParam(filename string) string

QueryParam returns the hash for the given filename as a query parameter.

type ResponseBuffer

type ResponseBuffer struct {
	// contains filtered or unexported fields
}

ResponseBuffer is the current response being composed by its owner. It implements http.ResponseWriter and io.WriterTo.

func (*ResponseBuffer) Header

func (rb *ResponseBuffer) Header() http.Header

Header implements the http.ResponseWriter interface.

func (*ResponseBuffer) Write

func (rb *ResponseBuffer) Write(p []byte) (int, error)

Write implements the http.ResponseWriter interface.

func (*ResponseBuffer) WriteHeader

func (rb *ResponseBuffer) WriteHeader(status int)

WriteHeader implements the http.ResponseWriter interface.

func (*ResponseBuffer) WriteTo

func (rb *ResponseBuffer) WriteTo(w http.ResponseWriter) error

WriteTo implements the io.WriterTo interface.

Source Files

doc.go respbuf.go static.go

Version
v0.0.0-20240124133021-55358d4d592d (latest)
Published
Jan 24, 2024
Platform
linux/amd64
Imports
9 packages
Last checked
2 days ago

Tools for package owners.