Make Status a type

Using a type is better than using an integer.
This commit is contained in:
Adnan Maolood
2021-02-20 16:15:26 -05:00
parent 99a8f09c22
commit 8938038797
6 changed files with 47 additions and 44 deletions

View File

@@ -102,7 +102,7 @@ func do(req *gemini.Request, via []*gemini.Request) (*gemini.Response, error) {
return resp, err
}
switch gemini.StatusClass(resp.Status) {
switch resp.Status.Class() {
case gemini.StatusInput:
input, ok := getInput(resp.Meta, resp.Status == gemini.StatusSensitiveInput)
if !ok {
@@ -155,7 +155,7 @@ func main() {
defer resp.Body.Close()
// Handle response
if gemini.StatusClass(resp.Status) == gemini.StatusSuccess {
if resp.Status.Class() == gemini.StatusSuccess {
body, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)