wwwserver

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2021 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var COMPRESS = true
View Source
var DefaultIndexNames []string = []string{"index.html"}
View Source
var DefaultMimeTypes map[string]string = map[string]string{
	".bin":   "application/octet-stream",
	".css":   "text/css",
	".gif":   "image/gif",
	".html":  "text/html",
	".js":    "application/javascript",
	".json":  "application/json",
	".png":   "image/png",
	".svg":   "image/svg+xml",
	".txt":   "text/plain",
	".wasm":  "application/wasm",
	".woff2": "font/woff2",
}

Functions

This section is empty.

Types

type File

type File struct {
	FileData
}

func NewFile

func NewFile(path string, mimeType string) (*File, error)

path here is absolute on this filesystem

func (*File) Freeze added in v0.6.0

func (f *File) Freeze() error

func (*File) Serve

func (f *File) Serve(resp *ResponseWriter, req *http.Request) error

func (*File) ServeStatus

func (f *File) ServeStatus(resp *ResponseWriter, req *http.Request, status int) error

type FileData

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

func (*FileData) ServeFrozen

func (f *FileData) ServeFrozen(resp *ResponseWriter, req *http.Request) error

func (*FileData) ServeStatus

func (f *FileData) ServeStatus(resp *ResponseWriter, req *http.Request, status int) error

type HTML

type HTML struct {
	FileData
	// contains filtered or unexported fields
}

func Default404

func Default404(tryPath string) *HTML

page not found

func Default503

func Default503() *HTML

func NewHTML

func NewHTML(path string) (*HTML, error)

func (*HTML) Freeze added in v0.6.0

func (h *HTML) Freeze() error

func (*HTML) Serve

func (h *HTML) Serve(resp *ResponseWriter, req *http.Request) error

func (*HTML) ServeStatus

func (h *HTML) ServeStatus(resp *ResponseWriter, req *http.Request, status int) error

type Resource

type Resource interface {
	Serve(resp *ResponseWriter, req *http.Request) error
	ServeFrozen(resp *ResponseWriter, req *http.Request) error
	Freeze() error
}

type ResponseWriter

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

func NewResponseWriter

func NewResponseWriter(resp http.ResponseWriter) *ResponseWriter

func (*ResponseWriter) Header

func (r *ResponseWriter) Header() http.Header

func (*ResponseWriter) Size

func (r *ResponseWriter) Size() int64

func (*ResponseWriter) Status

func (r *ResponseWriter) Status() int

func (*ResponseWriter) Write

func (r *ResponseWriter) Write(b []byte) (int, error)

func (*ResponseWriter) WriteError

func (r *ResponseWriter) WriteError(msg string)

func (*ResponseWriter) WriteHeader

func (r *ResponseWriter) WriteHeader(statusCode int)

type Tree

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

func NewTree

func NewTree(root string, indexNames []string, mimeTypes map[string]string,
	notFoundPath string) (*Tree, error)

func (*Tree) Freeze added in v0.6.0

func (t *Tree) Freeze() error

func (*Tree) Serve

func (t *Tree) Serve(resp *ResponseWriter, req *http.Request) error

func (*Tree) ServeFrozen

func (t *Tree) ServeFrozen(resp *ResponseWriter, req *http.Request) error

Jump to

Keyboard shortcuts

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