cute prototype

This commit is contained in:
JackDoan
2026-01-23 13:12:46 -06:00
parent 0b02d982b2
commit 8bb6090ffd
9 changed files with 162 additions and 40 deletions

View 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))
}