more better names to stuff

This commit is contained in:
Fabricio 2019-06-20 20:44:42 -03:00
parent 0e08d14d1f
commit a675ea390e

View file

@ -27,7 +27,7 @@ const StatusInternalProxyError = 999
func main() { func main() {
config := ReadConfig() config := ReadConfig()
proxyURL := fmt.Sprintf("http://localhost:%s", config.ProxyPort) proxyURL := "http://localhost:" + config.ProxyPort
fmt.Printf("\nListening on %s", proxyURL) fmt.Printf("\nListening on %s", proxyURL)
fmt.Printf("\n %s%s\n\n", proxyURL, config.DashboardPath) fmt.Printf("\n %s%s\n\n", proxyURL, config.DashboardPath)
@ -140,7 +140,7 @@ func NewPluginHandler(next http.HandlerFunc) http.HandlerFunc {
continue continue
} }
if strings.HasSuffix(file.Name(), ".so") { if strings.HasSuffix(file.Name(), ".so") {
fmt.Printf("loading plugin '%s'\n", file.Name()) fmt.Printf("Loading plugin '%s'\n", file.Name())
p, err := plugin.Open(exPath + "/" + file.Name()) p, err := plugin.Open(exPath + "/" + file.Name())
if err != nil { if err != nil {
fmt.Println("error: could not open plugin:", err) fmt.Println("error: could not open plugin:", err)
@ -162,7 +162,7 @@ func NewPluginHandler(next http.HandlerFunc) http.HandlerFunc {
return next return next
} }
// NewRecorderHandler saves all the traffic data // NewRecorderHandler records all the traffic data
func NewRecorderHandler(srv *CaptureService, next http.HandlerFunc) http.HandlerFunc { func NewRecorderHandler(srv *CaptureService, next http.HandlerFunc) http.HandlerFunc {
return func(rw http.ResponseWriter, req *http.Request) { return func(rw http.ResponseWriter, req *http.Request) {
@ -197,7 +197,7 @@ func NewProxyHandler(URL string) http.HandlerFunc {
url, _ := url.Parse(URL) url, _ := url.Parse(URL)
proxy := httputil.NewSingleHostReverseProxy(url) proxy := httputil.NewSingleHostReverseProxy(url)
proxy.ErrorHandler = func(rw http.ResponseWriter, req *http.Request, err error) { proxy.ErrorHandler = func(rw http.ResponseWriter, req *http.Request, err error) {
fmt.Printf("uh oh | %v | %s %s\n", err, req.Method, req.URL) fmt.Printf("Uh oh | %v | %s %s\n", err, req.Method, req.URL)
rw.WriteHeader(StatusInternalProxyError) rw.WriteHeader(StatusInternalProxyError)
fmt.Fprintf(rw, "%v", err) fmt.Fprintf(rw, "%v", err)
} }