io

package module
v0.0.0-...-3aa4d5a Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2019 License: MIT Imports: 13 Imported by: 0

README

io

This is the new IO package for dealing with Go routing

GitHub GitHub pull requests Go Report Card GoDoc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MiddlewareLog

func MiddlewareLog(next http.HandlerFunc, logger Logger) http.HandlerFunc

MiddlewareLog writes a log message for

func ServeFile

func ServeFile(w http.ResponseWriter, r *http.Request, fileSystem http.FileSystem, fileName string, prefix string) ([]byte, error)

ServeFile from a http.FileSystem

Types

type FileSystems

type FileSystems []http.FileSystem

FileSystems is a wrapper for multiple http.FileSystem

func (FileSystems) Open

func (f FileSystems) Open(name string) (http.File, error)

Open a file from the first http.FileSystem it is found in

type Log

type Log struct {
	Severity  Severity
	Message   string
	Timestamp time.Time
	Context   interface{}
}

Log entry

type Logger

type Logger struct {
	Writter    Writter
	Formatter  func(Log) []byte
	ShouldPool bool

	SpoolTriggerSeverity Severity
	// contains filtered or unexported fields
}

Logger writes log messages to a buffer

type Reader

type Reader interface {
	Read([]byte) error
}

Reader allows something to be read

type ReaderWritter

type ReaderWritter interface {
	Reader
	Writter
}

ReaderWritter allows something to be read or written

type SPA

type SPA struct {
	FileSystem http.FileSystem
	Index      string
	// contains filtered or unexported fields
}

SPA is an http.Handler that serves static files from a http.FileSystem. If a static file can not be found, the index file is served.

func (*SPA) EnableCSP

func (s *SPA) EnableCSP() error

EnableCSP generates saves the CSP header to be added to requests of the index file

func (SPA) ServeHTTP

func (s SPA) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP satisfies the http.Handler interface

type Severity

type Severity int

Severity level for log messages

type Writter

type Writter interface {
	Write([]byte) error
}

Writter allows something to be written

Jump to

Keyboard shortcuts

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