First implementaion of a web server

First implementation of a web server with oauth2 functionality. Nothing fancy, it just returns the username.
Three more arguments: -p for a port the web server shall run on and -ci and -cs for oauth2 ClientID and ClientSecret.
This commit is contained in:
da
2017-01-08 20:15:09 +01:00
parent b04eaf6978
commit 90e628b517
2 changed files with 89 additions and 0 deletions
+11
View File
@@ -730,10 +730,21 @@ func main() {
Shard = flag.String("s", "", "Shard ID")
ShardCount = flag.String("c", "", "Number of shards")
Owner = flag.String("o", "", "Owner ID")
Port = flag.Int("p", 0, "Web server port")
Ci = flag.Int("ci", 0, "ClientID")
Cs = flag.String("cs", "", "ClientSecret")
err error
)
flag.Parse()
// Start Webserver if a valid port is provided and if ClientID and ClientSecret are set
if *Port != 0 && *Port >= 1 && *Ci != 0 && *Cs != "" {
log.Infoln("Starting web server on port " + strconv.Itoa(*Port))
go startWebServer(strconv.Itoa(*Port), strconv.Itoa(*Ci), *Cs)
} else {
log.Infoln("Required web server arguments missing or invalid. Skipping web server start.")
}
if *Owner != "" {
OWNER = *Owner
}