-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
43 lines (34 loc) · 864 Bytes
/
main.go
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
36
37
38
39
40
41
42
43
package main
import (
"flag"
"fmt"
"github.com/ncw/swift"
zippo "github.com/picocandy/zippo/api"
"log"
"net/http"
"runtime"
)
var cf swift.Connection
func init() {
runtime.GOMAXPROCS(runtime.NumCPU())
cf = zippo.NewConnection()
}
func main() {
address := flag.String("address", "0.0.0.0", "Bind to HOST address (default: 0.0.0.0)")
port := flag.String("port", "5020", "Use PORT (default: 5020)")
flag.Parse()
err := zippo.UpdateAccountMetaTempURL(cf)
if err != nil {
log.Fatal(err)
}
h := zippo.NewHandler(cf)
mux := http.NewServeMux()
mux.HandleFunc("/", zippo.HomeHandler)
mux.HandleFunc("/version", zippo.VersionHandler)
mux.HandleFunc("/z", h.ZipUpload)
mux.HandleFunc("/u", h.Upload)
bind := fmt.Sprintf("%s:%s", *address, *port)
if err := http.ListenAndServe(bind, zippo.LogHandler(mux)); err != nil {
log.Fatal(err)
}
}