Last active
August 7, 2017 00:01
-
-
Save DennyLoko/9bed26a6d175d1fd3f6a to your computer and use it in GitHub Desktop.
This simple application is made to inspect the request sent to other webservers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
// This simple application is made to inspect the request sent to other | |
// webservers. Simply edit your hosts file and point the address to your IP. | |
// You must be root to use port 80. | |
// Don't forget to: go get -u github.com/valyala/fasthttp | |
import ( | |
"flag" | |
"fmt" | |
"log" | |
"github.com/valyala/fasthttp" | |
) | |
var ( | |
addr = flag.String("addr", ":8080", "TCP address to listen to") | |
) | |
func main() { | |
flag.Parse() | |
log.Printf("Starting HTTP server on %q", *addr) | |
go func() { | |
if err := fasthttp.ListenAndServe(*addr, requestHandler); err != nil { | |
log.Fatalf("error in ListenAndServe: %s", err) | |
} | |
}() | |
select {} | |
} | |
func requestHandler(ctx *fasthttp.RequestCtx) { | |
fmt.Println(fmt.Sprintf("---RAW---\n%s\n---/RAW---", &ctx.Request)) | |
ctx.SetContentType("text/plain; charset=utf8") | |
fmt.Fprintln(ctx, "Ok") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment