pastebin/main.go

36 lines
684 B
Go
Raw Normal View History

2017-07-03 06:42:34 +00:00
package main
import (
"log"
2017-07-03 06:57:32 +00:00
"time"
2017-07-03 06:42:34 +00:00
"github.com/namsral/flag"
)
2017-07-09 17:18:41 +00:00
var cfg Config
2017-07-03 06:42:34 +00:00
func main() {
var (
config string
bind string
fqdn string
2017-07-03 06:57:32 +00:00
expiry time.Duration
2017-07-03 06:42:34 +00:00
)
flag.StringVar(&config, "config", "", "config file")
flag.StringVar(&bind, "bind", "0.0.0.0:8000", "[int]:<port> to bind to")
flag.StringVar(&fqdn, "fqdn", "localhost", "FQDN for public access")
2017-07-03 06:57:32 +00:00
flag.DurationVar(&expiry, "expiry", 5*time.Minute, "expiry time for pastes")
2017-07-03 06:42:34 +00:00
flag.Parse()
2017-07-03 06:57:32 +00:00
if expiry.Seconds() < 60 {
log.Fatalf("expiry of %s is too small", expiry)
}
2017-07-03 06:42:34 +00:00
// TODO: Abstract the Config and Handlers better
cfg.fqdn = fqdn
cfg.expiry = expiry
NewServer(bind, cfg).ListenAndServe()
}