aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdnan Maolood <[email protected]>2021-01-10 00:10:57 -0500
committerAdnan Maolood <[email protected]>2021-01-10 00:10:57 -0500
commit3ed39e62d8952391287bd4ebf54a4893e3e6411b (patch)
tree8c44fa8d5934340e425809981a2a7954ebf9c7f0
parentAdd missing error handling (diff)
downloadgo-gemini-3ed39e62d8952391287bd4ebf54a4893e3e6411b.tar.xz
go-gemini-3ed39e62d8952391287bd4ebf54a4893e3e6411b.zip
Rename status.Message to status.Meta
-rw-r--r--examples/client.go2
-rw-r--r--server.go11
-rw-r--r--status.go16
3 files changed, 8 insertions, 21 deletions
diff --git a/examples/client.go b/examples/client.go
index f707f04..e3c7537 100644
--- a/examples/client.go
+++ b/examples/client.go
@@ -146,7 +146,7 @@ func main() {
}
fmt.Print(string(body))
} else {
- fmt.Printf("%d %s: %s\n", resp.Status, resp.Status.Message(), resp.Meta)
+ fmt.Printf("%d %s\n", resp.Status, resp.Meta)
os.Exit(1)
}
}
diff --git a/server.go b/server.go
index 8d09382..ecfd62d 100644
--- a/server.go
+++ b/server.go
@@ -266,15 +266,10 @@ func (w *ResponseWriter) Header(status Status, meta string) {
// Status sets the response header to the given status code.
//
-// Status is equivalent to Header(status, status.Message())
+// Status is equivalent to Header(status, status.Meta())
func (w *ResponseWriter) Status(status Status) {
- meta := status.Message()
-
- if status.Class() == StatusClassSuccess {
- meta = w.mediatype
- }
-
- w.Header(status, meta)
+ w.status = status
+ w.meta = status.Meta()
}
// SetMediaType sets the media type that will be written for a successful response.
diff --git a/status.go b/status.go
index db87488..aebb445 100644
--- a/status.go
+++ b/status.go
@@ -41,19 +41,11 @@ func (s Status) Class() StatusClass {
return StatusClass(s / 10)
}
-// Message returns a status message corresponding to this status code.
-func (s Status) Message() string {
+// Meta returns a description of the status code appropriate for use in a response.
+//
+// Meta returns an empty string for input, success, and redirect status codes.
+func (s Status) Meta() string {
switch s {
- case StatusInput:
- return "Input"
- case StatusSensitiveInput:
- return "Sensitive input"
- case StatusSuccess:
- return "Success"
- case StatusRedirect:
- return "Redirect"
- case StatusPermanentRedirect:
- return "Permanent redirect"
case StatusTemporaryFailure:
return "Temporary failure"
case StatusServerUnavailable: