Newer
Older
package main
import (
"io/ioutil"
"log"
"net/http"
logrus.Info("Starting AKMS Simulator...")
http.HandleFunc("/api/v1/keys/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)
logrus.Errorf("Method not allowed: %s", r.Method)
return
}
body, err := ioutil.ReadAll(r.Body)
if err != nil {
http.Error(w, "Failed to read request body", http.StatusInternalServerError)
logrus.Errorf("Failed to read request body: %s", err)
logrus.Info("Request came from: " + ip + "; Body: " + string(body))
w.WriteHeader(http.StatusNoContent)