serve

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2021 License: MIT Imports: 16 Imported by: 0

README

serve

Documentation

Index

Constants

View Source
const (
	IndexFileName = "index.html"

	DefaultRangeBufferSize = 1 << 22 // 4 MiB

	MimeHeader        = "Content-Type"
	SizeHeader        = "Content-Length"
	ModTimeHeader     = "Last-Modified"
	DispositionHeader = "Content-Disposition"
)

Variables

View Source
var ErrMethodNotAllowed = errors.New("method not allowed")
View Source
var (
	JSONMime = Mime("application/json; charset=utf-8")
)

Functions

func App

func App(fsys fs.FS, indexFile string, opts ...Option) http.Handler

func Bytes

func Bytes(w http.ResponseWriter, r *http.Request,
	data []byte, opts ...Option) (int64, error)

func Error

func Error(w http.ResponseWriter, err error)

func FSFile

func FSFile(w http.ResponseWriter, r *http.Request,
	fsys fs.FS, name string, opts ...Option) (int64, error)

func File

func File(w http.ResponseWriter, r *http.Request,
	f fs.File, opts ...Option) (int64, error)

func Handle

func Handle(w http.ResponseWriter, r *http.Request, fn func() (int64, error))

func JSON

func JSON(w http.ResponseWriter, r *http.Request, v interface{}, opts ...Option) (int64, error)

func Reader

func Reader(rw http.ResponseWriter, req *http.Request,
	r io.Reader, opts ...Option) (int64, error)

Types

type Option

type Option func(c *config)

func Attachment

func Attachment(name string) Option

func Compress

func Compress(b bool) Option

func Immutable

func Immutable(b bool) Option

func MaxAge

func MaxAge(d time.Duration) Option

func Mime

func Mime(s string) Option

func ModTime

func ModTime(t time.Time) Option

func Size

func Size(n int64) Option

func SizeOf

func SizeOf(data []byte) Option

Jump to

Keyboard shortcuts

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