main.go
// Command vitrine is a tiny read-only web viewer for local source trees.
//
// Each configured exhibit is served under its name as a URL prefix,
// e.g. "/moonshot-1/crates/iri/filetests/verify-errors.md".
// The default view is rendered (markdown becomes HTML, directories become listings);
// appending "?fmt=raw" serves the file bytes directly.
//
// Exhibits come from a YAML config file given via the required -config flag;
// see config.go for the schema and README.md for examples.
package main
import (
"flag"
"log"
"net/http"
)
func main() {
addr := flag.String("addr", ":8000", "listen address")
configPath := flag.String("config", "", "path to config file (required)")
flag.Parse()
if *configPath == "" {
log.Fatal("the -config flag is required; there is no default config location")
}
cfg, err := loadConfig(*configPath)
if err != nil {
log.Fatal(err)
}
srv, err := newServer(cfg.Exhibits)
if err != nil {
log.Fatal(err)
}
log.Printf("vitrine listening on %s", *addr)
log.Fatal(http.ListenAndServe(*addr, srv))
}
main.go · 1.0 KiB · 6c942a8c45