Skip to content

Commit

Permalink
Send a sample HTTP request.
Browse files Browse the repository at this point in the history
The code does roughly the same thing as starterkit-csharp.
https://github.com/icfpcontest2020/starterkit-csharp/blob/master/app/Program.cs
  • Loading branch information
nya3jp authored and beevee committed Jul 1, 2020
1 parent 06f72fb commit d3873ec
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,24 @@ package main

import (
"fmt"
"log"
"net/http"
"os"
)

func main() {
fmt.Printf("%s %s\n", os.Args[1], os.Args[2])
serverURL := os.Args[1]
playerKey := os.Args[2]

fmt.Printf("ServerUrl: %s; PlayerKey: %s\n", serverURL, playerKey)

res, err := http.Get(fmt.Sprintf("%s?playerKey=%s", serverURL, playerKey))
if err != nil {
log.Fatalf("Failed: %v", err)
}
defer res.Body.Close()

if res.StatusCode != http.StatusOK {
log.Fatalf("Failed: got status %d, want %d", res.StatusCode, http.StatusOK)
}
}

0 comments on commit d3873ec

Please sign in to comment.