aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdnan Maolood <[email protected]>2021-02-17 12:06:22 -0500
committerAdnan Maolood <[email protected]>2021-02-17 12:06:43 -0500
commitec22e762c3f5ac1cd9e8673c4ed678e5d6a8900f (patch)
treea3cf527b70e11761094d2eccb2d95b8297bd80ce
parentMove ResponseWriter.Flush to Flusher interface (diff)
downloadgo-gemini-ec22e762c3f5ac1cd9e8673c4ed678e5d6a8900f.tar.xz
go-gemini-ec22e762c3f5ac1cd9e8673c4ed678e5d6a8900f.zip
Rename Meta to StatusText
Rename Meta to StatusText and support all status codes.
-rw-r--r--response.go4
-rw-r--r--status.go18
2 files changed, 15 insertions, 7 deletions
diff --git a/response.go b/response.go
index bb25f1b..ea2184b 100644
--- a/response.go
+++ b/response.go
@@ -139,7 +139,7 @@ type ResponseWriter interface {
Header(status int, meta string)
// Status sets the response status code.
- // It also sets the response meta to Meta(status).
+ // It also sets the response meta to StatusText(status).
Status(status int)
// Meta sets the response meta.
@@ -195,7 +195,7 @@ func (w *responseWriter) Header(status int, meta string) {
func (w *responseWriter) Status(status int) {
w.status = status
- w.meta = Meta(status)
+ w.meta = StatusText(status)
}
func (w *responseWriter) Meta(meta string) {
diff --git a/status.go b/status.go
index 630bfa1..beef99f 100644
--- a/status.go
+++ b/status.go
@@ -28,12 +28,20 @@ func StatusClass(status int) int {
return (status / 10) * 10
}
-// Meta returns a description of the provided status code appropriate
-// for use in a response.
-//
-// Meta returns an empty string for input, success, and redirect status codes.
-func Meta(status int) string {
+// StatusText returns a text for the provided status code.
+// It returns the empty string if the status code is unknown.
+func StatusText(status int) string {
switch status {
+ case StatusInput:
+ return "Input"
+ case StatusSensitiveInput:
+ return "Sensitive input"
+ case StatusSuccess:
+ return "Success"
+ case StatusRedirect:
+ return "Reidrect"
+ case StatusPermanentRedirect:
+ return "Permanent redirect"
case StatusTemporaryFailure:
return "Temporary failure"
case StatusServerUnavailable: