New function GetReason to get HTTP reason phrase from an http.Request

This commit is contained in:
Roberto Abdelkader Martínez Pérez
2019-10-02 16:20:39 +02:00
parent 3602dc71f2
commit f32beffd33
2 changed files with 62 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
package http
import (
"net/http"
"strings"
)
func GetReason(r *http.Response) string {
if i := strings.IndexByte(r.Status, ' '); i != -1 {
return r.Status[i+1:]
} else {
return ""
}
}