Documentation ¶
Overview ¶
Package owl provides an implementation of a file server for the Bird protocol.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorHandler ¶ added in v0.5.0
ErrorHandler is like a bird.Handler that responds to an error. It can be used to write a response to a Bird request and log errors, for example.
type FileServer ¶
type FileServer struct { FS fs.FS ErrHn ErrorHandler }
FileServer is a seed.Handler that can serve Seed documents from a filesystem.
FS is the filesystem used and ErrHn is used to handle errors.
func NewFileServer ¶
func NewFileServer(fsys fs.FS, errHn ErrorHandler) (fsrv *FileServer, err error)
NewFileServer creates a new FileServer for fsys registering errHn as the error handler. errHn can be nil.
func (*FileServer) ServeBird ¶
func (fsrv *FileServer) ServeBird(u *url.URL, sw *seed.Writer)
ServeBird serves the requested Seed document.
Only files that end in seed.Extension are served. However, Bird request URLs must omit the extension. If the URL path refers to a directory, a file with the name of just seed.Extension will be served if it exists.
Filesystem:
abc abc/.sd abc/1.sd xyz xyz/.sd xyz.sd
For this filesystem, where * is the host, ServeBird would respond as such:
bird://*/abc -> abc/.sd bird://*/abc/1 -> abc/1.sd bird://*/xyz -> xyz.sd
If an error occurs opening a requested file, ErrHn is called using the error and u and sw from the request and the error that occured. If ErrHn is nil, the error is skipped and no response is made.