A very simple API that returns different HTTP Status Classes
for various HTTP Status Codes
(like Successful
for http.StatusOK
or ClientError
for http.StatusBadRequest
).
import (
"net/http"
"github.com/jaebradley/go-http-status-class"
)
var r http.Response;
r.StatusCode = http.StatusOK
statusClass := httpstatusclass.IdentifyResponseStatusClass(r)
fmt.Println(statusClass) // This should print "Successful"
statusClass2 := httpstatusclass.IdentifyStatusClass(-1)
fmt.Println(statusClass) // This should print "Unknown"