Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Bastien Gounon
xcache-flusher
Commits
035fbe83
Commit
035fbe83
authored
Jul 31, 2020
by
Bastien Gounon
🐗
Browse files
ability to set port at server start
parent
c7143a5b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
1 deletion
+6
-1
main.go
main.go
+6
-1
No files found.
main.go
View file @
035fbe83
...
...
@@ -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
)
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment