cmd/reqecho: utility to dump webhook requests
This commit is contained in:
		
							
								
								
									
										23
									
								
								cmd/reqecho/main.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								cmd/reqecho/main.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | ||||
| package main | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"net/http" | ||||
| 	"net/http/httputil" | ||||
| 	"os" | ||||
| ) | ||||
|  | ||||
| func main() { | ||||
| 	http.ListenAndServe(":3369", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||||
| 		b, err := httputil.DumpRequest(r, true) | ||||
| 		fmt.Printf("%v\n%s\n\n", err, b) | ||||
| 		f, err := os.Create("prev.txt") | ||||
| 		if err != nil { | ||||
| 			panic(err) | ||||
| 		} | ||||
| 		if _, err := f.Write(b); err != nil { | ||||
| 			panic(err) | ||||
| 		} | ||||
| 		os.Exit(0) | ||||
| 	})) | ||||
| } | ||||
		Reference in New Issue
	
	Block a user