-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathmain.go
More file actions
35 lines (27 loc) · 684 Bytes
/
main.go
File metadata and controls
35 lines (27 loc) · 684 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package main
import (
"log"
"time"
"github.com/namsral/flag"
)
var cfg Config
func main() {
var (
config string
bind string
fqdn string
expiry time.Duration
)
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")
flag.DurationVar(&expiry, "expiry", 5*time.Minute, "expiry time for pastes")
flag.Parse()
if expiry.Seconds() < 60 {
log.Fatalf("expiry of %s is too small", expiry)
}
// TODO: Abstract the Config and Handlers better
cfg.fqdn = fqdn
cfg.expiry = expiry
NewServer(bind, cfg).ListenAndServe()
}