Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileServer ¶
FileServer serves file
Example ¶
Enable directory listings by setting ListDirectory on the FileServer value instead of using the New constructor. With it off (the default), a request for a directory falls through to the next handler rather than listing it.
package main
import (
"github.com/moonrhythm/parapet"
"github.com/moonrhythm/parapet/pkg/fileserver"
)
func main() {
s := parapet.New()
s.Use(&fileserver.FileServer{
Root: "/srv/downloads",
ListDirectory: true,
})
}
Output:
func New ¶
func New(root string) *FileServer
New creates new file server
Example ¶
Serve static files from a directory. A request that matches no file falls through to the next middleware in the chain, so put fileserver near the end to use it as a static-file layer in front of an application handler.
package main
import (
"github.com/moonrhythm/parapet"
"github.com/moonrhythm/parapet/pkg/fileserver"
)
func main() {
s := parapet.New()
s.Use(fileserver.New("/var/www/public"))
// s.Use(...) — handles requests for paths with no matching file.
}
Output:
func (FileServer) ServeHandler ¶
func (m FileServer) ServeHandler(h http.Handler) http.Handler
ServeHandler implements middleware interface
Click to show internal directories.
Click to hide internal directories.