Skip to content

Instantly share code, notes, and snippets.

Last active October 29, 2016 09:29
What would you like to do?
FROM busybox
ADD gecho /
ENTRYPOINT ["/gecho"]
package main
import (
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Printf("-- Request Start --\n")
fmt.Printf("%s %s\n", r.Method, r.RequestURI)
for k := range r.Header {
fmt.Printf("%s: %s\n", k, r.Header[k])
if r.ContentLength > 0 {
body, err := ioutil.ReadAll(r.Body)
if err != nil {
fmt.Printf("Error reading body\n")
} else {
fmt.Printf("%s\n", body)
w.Header().Set("Server", "Gecho Server")
fmt.Printf("-- Request End --\n\n")
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":8080", nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment