You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
466 B
29 lines
466 B
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"net/http"
|
|
"log"
|
|
)
|
|
|
|
type Data struct {
|
|
identifier string
|
|
password string
|
|
}
|
|
|
|
func handleRequest(w http.ResponseWriter, r *http.Request) {
|
|
var data Data
|
|
err := json.NewDecoder(r.Body).Decode(&data)
|
|
if err != nil {
|
|
http.Error(w,err.Error(), http.StatusBadRequest)
|
|
return
|
|
}
|
|
fmt.Fprintf(w, "Data: %+v", data)
|
|
}
|
|
|
|
func main() {
|
|
http.HandleFunc("/", handleRequest)
|
|
log.Fatal(http.ListenAndServe(":8088", nil))
|
|
}
|