main.go 664 B

123456789101112131415161718192021222324252627282930313233343536
  1. package main
  2. import (
  3. "flag"
  4. "log"
  5. "github.com/kellegous/go/context"
  6. "github.com/kellegous/go/web"
  7. )
  8. var version string
  9. func getVersion() string {
  10. if version == "" {
  11. return "none"
  12. }
  13. return version
  14. }
  15. func main() {
  16. flagData := flag.String("data", "data",
  17. "The location to use for the data store")
  18. flagAddr := flag.String("addr", ":8067",
  19. "The address that the HTTP server will bind")
  20. flagAdmin := flag.Bool("admin", false,
  21. "If allowing admin level requests")
  22. flag.Parse()
  23. ctx, err := context.Open(*flagData)
  24. if err != nil {
  25. log.Panic(err)
  26. }
  27. defer ctx.Close()
  28. log.Panic(web.ListenAndServe(*flagAddr, *flagAdmin, getVersion(), ctx))
  29. }