Documentation ¶
Index ¶
- Variables
- func DefaultIndexPageHandler(indexFilePath string) http.Handler
- func NewHandlerWithOptions(opts ...Option) (http.Handler, error)
- type Logger
- type Option
- func Host(host string) Option
- func IndexPageHandler(index http.Handler) Option
- func Log(l Logger) Option
- func ModuleServerURL(moduleServerURL string) Option
- func RobotsTxt(robotsTxt string) Option
- func StaticDir(path, URLPath string) Option
- func VCS(vcs string) Option
- func VCSURL(vcsURL string) Option
Constants ¶
This section is empty.
Variables ¶
var DefaultRobotsTxt = `user-agent: *
Allow: /$
Allow: /.static/*$
Disallow: /`
DefaultRobotsTxt is the default value for /robots.txt file.
var ErrNotReadable = errors.New("vanity: static dir path directory is not readable")
Functions ¶
func DefaultIndexPageHandler ¶
DefaultIndexPageHandler serves given indexFilePath over HTTP via http.ServeFile(w, r, name).
func NewHandlerWithOptions ¶
Handler is an HTTP middleware that redirects browsers to Go module server (pkg.go.dev or similar) or Go cmd line tool to VCS repository. Handler can be configured by providing options. VCS repository is git by default. VCS can be set with VCS(). Configurable Logger defaults to os.Stderr. Logger can be configured with SetLogger(). Module server URL is https://pkg.go.dev/ and it can be configured via ModuleServerURL() func. VCSURL() func must be used to set VCS repository URL (such as https://github.com/kare/).
Types ¶
type Logger ¶ added in v0.2.0
type Logger interface {
Printf(format string, v ...interface{})
}
Logger describes functions available for logging purposes.
type Option ¶
Option represents a functional option for configuring the vanity middleware.
func IndexPageHandler ¶
IndexPageHandler sets a handler for index.html page.
func ModuleServerURL ¶
ModuleServerURL sets Go module server address for browser redirect.
func RobotsTxt ¶
RobotsTxt takes in a value for robots.txt. If value is empty, the value of `DefaultRobotsTxt` is used