mirror of https://github.com/goproxyio/goproxy
25 lines
476 B
Go
25 lines
476 B
Go
|
package proxy
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"log"
|
||
|
"net/http"
|
||
|
"os"
|
||
|
)
|
||
|
|
||
|
var errLogger = log.New(os.Stderr, "", log.LstdFlags)
|
||
|
|
||
|
func ReturnServerError(w http.ResponseWriter, err error) {
|
||
|
w.WriteHeader(500)
|
||
|
msg := fmt.Sprintf("%v", err)
|
||
|
errLogger.Printf("goproxy: %s\n", msg)
|
||
|
_, _ = w.Write([]byte(msg))
|
||
|
}
|
||
|
|
||
|
func ReturnBadRequest(w http.ResponseWriter, err error) {
|
||
|
w.WriteHeader(400)
|
||
|
msg := fmt.Sprintf("%v", err)
|
||
|
errLogger.Printf("goproxy: %s\n", msg)
|
||
|
_, _ = w.Write([]byte(msg))
|
||
|
}
|