-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.go
More file actions
28 lines (24 loc) · 694 Bytes
/
main.go
File metadata and controls
28 lines (24 loc) · 694 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
package main
import (
"flag"
"log"
"net/http"
"github.com/julienschmidt/httprouter"
"github.com/suyashkumar/getbin/handlers"
"golang.org/x/crypto/acme/autocert"
)
var domain = flag.String("domain", "",
"domain used for this currently running instance (enables SSL, and mints certs through LetsEncrypt")
func main() {
flag.Parse()
router := httprouter.New()
router.GET("/", handlers.Home)
router.GET("/:username/:repo", handlers.Download)
if *domain != "" {
log.Printf("Listening at https://%s", *domain)
log.Fatal(http.Serve(autocert.NewListener(*domain), router))
} else {
log.Printf("Listening at localhost:8000")
log.Fatal(http.ListenAndServe(":8000", router))
}
}