aboutsummaryrefslogtreecommitdiff
path: root/lib/http
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2024-03-15 03:21:42 +0700
committerShulhan <ms@kilabit.info>2024-03-15 03:39:16 +0700
commit625722e9087173d7b01acfb786de935fe09f4310 (patch)
tree319f73c68bfdd2cc07f5f2fff66a8c0b2e45c8b9 /lib/http
parente671f2a5eb1b7dd2f506150c55227eb5a886e4d6 (diff)
downloadpakakeh.go-625722e9087173d7b01acfb786de935fe09f4310.tar.xz
lib/http: refactoring type of ResponseType from int to string
The reason is to make storing or encoding the value readable from human point of view instead of number, 0, 1, 2, etc.
Diffstat (limited to 'lib/http')
-rw-r--r--lib/http/response_type.go16
-rw-r--r--lib/http/response_type_test.go12
2 files changed, 14 insertions, 14 deletions
diff --git a/lib/http/response_type.go b/lib/http/response_type.go
index 75fb7146..4fee2e88 100644
--- a/lib/http/response_type.go
+++ b/lib/http/response_type.go
@@ -4,17 +4,17 @@
package http
-// ResponseType define type for HTTP response.
-type ResponseType int
+// ResponseType define the content type for HTTP response.
+type ResponseType string
// List of valid response type.
const (
- ResponseTypeNone ResponseType = iota
- ResponseTypeBinary
- ResponseTypeHTML
- ResponseTypeJSON
- ResponseTypePlain
- ResponseTypeXML
+ ResponseTypeNone ResponseType = ``
+ ResponseTypeBinary ResponseType = `binary`
+ ResponseTypeHTML ResponseType = `html`
+ ResponseTypeJSON ResponseType = `json`
+ ResponseTypePlain ResponseType = `plain`
+ ResponseTypeXML ResponseType = `xml`
)
// String return the string representation of ResponseType as in
diff --git a/lib/http/response_type_test.go b/lib/http/response_type_test.go
index f95726c2..efbc2114 100644
--- a/lib/http/response_type_test.go
+++ b/lib/http/response_type_test.go
@@ -15,12 +15,12 @@ func TestResponseType_String(t *testing.T) {
exp string
restype ResponseType
}{
- {restype: 0, exp: ""},
- {restype: 1, exp: ContentTypeBinary},
- {restype: 2, exp: ContentTypeHTML},
- {restype: 3, exp: ContentTypeJSON},
- {restype: 4, exp: ContentTypePlain},
- {restype: 5, exp: ContentTypeXML},
+ {restype: ``, exp: ``},
+ {restype: `binary`, exp: ContentTypeBinary},
+ {restype: `html`, exp: ContentTypeHTML},
+ {restype: `json`, exp: ContentTypeJSON},
+ {restype: `plain`, exp: ContentTypePlain},
+ {restype: `xml`, exp: ContentTypeXML},
{restype: ResponseTypeNone, exp: ""},
{restype: ResponseTypeBinary, exp: ContentTypeBinary},
{restype: ResponseTypeHTML, exp: ContentTypeHTML},