Commit 035fbe83 authored by Bastien Gounon's avatar Bastien Gounon 🐗
Browse files

ability to set port at server start

parent c7143a5b
......@@ -4,6 +4,7 @@ import (
"flag"
"log"
"net/http"
"strconv"
"github.com/gin-gonic/gin"
)
......@@ -11,7 +12,10 @@ import (
func main() {
var dir, serverToken string
var port int
flag.StringVar(&dir, "cachedir", "", "Folder where the cache is stored")
flag.IntVar(&port, "port", 8080, "Network port where the server should listen")
flag.StringVar(&serverToken, "token", "", " optional - Token for user authentication")
flag.Parse()
......@@ -20,6 +24,7 @@ func main() {
}
r := gin.Default()
r.DELETE("/flush", func(c *gin.Context) {
userToken := c.Query("token")
if userToken != serverToken {
......@@ -34,5 +39,5 @@ func main() {
}
})
r.Run()
r.Run(":" + strconv.Itoa(port))
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment