aboutsummaryrefslogtreecommitdiff
path: root/cmd/whoisfront/main.go
diff options
context:
space:
mode:
authorChristine Dodrill <me@christine.website>2019-09-21 20:58:15 +0000
committerChristine Dodrill <me@christine.website>2019-09-21 20:58:15 +0000
commit5965da82d217d5247d17064c0dc4e5ef4a0dbe16 (patch)
treedc7715f53379c82aa0adaa2b03e62b94c966a240 /cmd/whoisfront/main.go
parent67b9d4f2657fd7c5cd180e5b9f3cfa9dc24677f1 (diff)
downloadx-5965da82d217d5247d17064c0dc4e5ef4a0dbe16.tar.xz
x-5965da82d217d5247d17064c0dc4e5ef4a0dbe16.zip
set front too
Diffstat (limited to 'cmd/whoisfront/main.go')
-rw-r--r--cmd/whoisfront/main.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/cmd/whoisfront/main.go b/cmd/whoisfront/main.go
index ce3aff7..1ae9f51 100644
--- a/cmd/whoisfront/main.go
+++ b/cmd/whoisfront/main.go
@@ -5,6 +5,7 @@ import (
"encoding/json"
"flag"
"fmt"
+ "io/ioutil"
"log"
"net/http"
"net/http/cgi"
@@ -31,6 +32,26 @@ func main() {
}
func handle(w http.ResponseWriter, r *http.Request) {
+ if r.Method == http.MethodPost {
+ front, err := ioutil.ReadAll(r.Body)
+ if err != nil {
+ panic(err)
+ }
+ defer r.Body.Close()
+ req := sc.Switch(string(front))
+ resp, err := http.DefaultClient.Do(req)
+ if err != nil {
+ panic(err)
+ }
+ err = switchcounter.Validate(resp)
+ if err != nil {
+ panic(err)
+ }
+ w.Header().Set("Content-Type", "text/plain")
+ fmt.Fprint(w, string(front))
+ return
+ }
+
req := sc.Status()
resp, err := http.DefaultClient.Do(req)
if err != nil {