-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
45 lines (35 loc) · 1.01 KB
/
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
44
45
package main
import (
"flag"
"log"
"strings"
"github.com/gin-gonic/gin"
)
var httpServerAddr string
var localServerAddr string
var storeDir string
var author string
// Mb
var uploadLimit int
func main() {
log.Default().SetFlags(log.Lshortfile | log.LstdFlags)
flag.StringVar(&httpServerAddr, "http", "0.0.0.0:8000", "HTTP listen addr")
flag.StringVar(&storeDir, "store", "/tmp/mailrender/", "Upload store directory")
flag.IntVar(&uploadLimit, "m", 50, "Size limit (MB)")
flag.StringVar(&author, "author", "restsend.com", "Exif/author meta info")
flag.Parse()
err := prepareStoreDir(storeDir)
if err != nil {
panic(err)
}
if strings.HasPrefix(httpServerAddr, ":") {
localServerAddr = "http://127.0.0.1" + httpServerAddr
} else {
localServerAddr = strings.Replace(httpServerAddr, "0.0.0.0", "http://127.0.0.1", 1)
}
gin.SetMode(gin.ReleaseMode)
r := gin.Default()
log.Println("Starting HTTP Server at http://"+httpServerAddr, "localaddr at", localServerAddr)
RegisterHandlers(r)
r.Run(httpServerAddr)
}