33 lines
503 B
Go
33 lines
503 B
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"log"
|
|
"math/rand"
|
|
"net/http"
|
|
)
|
|
|
|
func attempt(w http.ResponseWriter, req *http.Request) {
|
|
operation := "+"
|
|
if r := rand.Intn(2); r == 0 {
|
|
operation = "-"
|
|
}
|
|
|
|
r := map[string]string{
|
|
"operation": operation,
|
|
}
|
|
|
|
b, err := json.Marshal(r)
|
|
if err != nil {
|
|
log.Fatal("issue with json marshalling")
|
|
}
|
|
j := string(b)
|
|
fmt.Println(j)
|
|
fmt.Fprintf(w, j)
|
|
}
|
|
|
|
func problem(w http.ResponseWriter, req *http.Request) {
|
|
fmt.Fprintf(w, "hello world")
|
|
}
|