Documentation ¶
Overview ¶
Package tools implements various helpful tools for developing apps.
Index ¶
- func DefaultAssetServer(directory string) http.Handler
- func DefaultProtector() func(http.Handler) http.Handler
- func DefaultReporter() func(error)
- func DefaultRequestLogger() func(http.Handler) http.Handler
- func NewAssetServer(prefix, directory string) http.Handler
- func NewProtector(maxBody string, corsOptions cors.Options) func(http.Handler) http.Handler
- func NewReporter(out io.Writer) func(error)
- func NewRequestLogger(out io.Writer) func(http.Handler) http.Handler
- func UnwrapResponseWriter(w http.ResponseWriter) http.ResponseWriter
- type ResponseWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultAssetServer ¶
DefaultAssetServer constructs an AssetServer that servers the directory on the root path.
func DefaultProtector ¶
DefaultProtector constructs a middleware that by default limits the request body size to 4Ks and sets a basic CORS configuration.
func DefaultReporter ¶ added in v0.3.0
func DefaultReporter() func(error)
DefaultReporter returns a reporter that writes to stderr.
func DefaultRequestLogger ¶
DefaultRequestLogger constructs a handler that logs incoming requests to the operating systems standard output.
func NewAssetServer ¶
NewAssetServer constructs an asset server handler that serves an asset directory on a specified path and serves the index file for not found paths which is needed to run single page applications like Ember.
func NewProtector ¶
NewProtector constructs a middleware that implements basic protection measures for the passed endpoint. Currently the protector limits the body size to a the passed length and automatically handles CORS using the specified options.
func NewReporter ¶ added in v0.3.0
NewReporter returns a very basic reporter that writes errors and stack traces to the specified writer.
func NewRequestLogger ¶
NewRequestLogger constructs a handler that logs incoming requests to the specified writer output.
func UnwrapResponseWriter ¶ added in v0.4.4
func UnwrapResponseWriter(w http.ResponseWriter) http.ResponseWriter
UnwrapResponseWriter will try to unwrap the passed ResponseWriter.
Types ¶
type ResponseWriter ¶ added in v0.4.4
type ResponseWriter struct { http.ResponseWriter // contains filtered or unexported fields }
ResponseWriter is the ResponseWriter that wraps the original ResponseWriter if the Logger middleware has been used in the chain.
func (*ResponseWriter) WriteHeader ¶ added in v0.4.4
func (w *ResponseWriter) WriteHeader(statusCode int)
WriteHeader calls the underlying ResponseWriters WriteHeader method.