mirror of
https://github.com/slackhq/nebula.git
synced 2026-02-14 08:44:24 +01:00
cute prototype
This commit is contained in:
39
cmd/nebula-monitor/nebula-monitor.go
Normal file
39
cmd/nebula-monitor/nebula-monitor.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func handlePost(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodPost {
|
||||
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
|
||||
// Read the body
|
||||
body, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
http.Error(w, "Error reading body", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
defer r.Body.Close()
|
||||
|
||||
// Print to console
|
||||
//fmt.Printf("Path: %s\n", r.URL.Path)
|
||||
//fmt.Printf("Headers: %v\n", r.Header)
|
||||
fmt.Printf("%s\n", string(body))
|
||||
|
||||
// Send response
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write([]byte(""))
|
||||
}
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/", handlePost)
|
||||
|
||||
fmt.Println("Server starting on :8080")
|
||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||
}
|
||||
Reference in New Issue
Block a user