Newer
Older
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
)
func main() {
fmt.Println("Starting AKMS Simulator...")
http.HandleFunc("/push_ksa_key", handlePushKsaKey)
log.Fatal(http.ListenAndServe(":4444", nil))
}
func handlePushKsaKey(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
return
}
body, err := ioutil.ReadAll(r.Body)
if err != nil {
http.Error(w, "Failed to read request body", http.StatusInternalServerError)
return
}
ip := r.RemoteAddr
fmt.Println("Request came from: " + ip + "; Body: " + string(body))
}