response: Revert to using fields instead of methods

This commit is contained in:
Adnan Maolood
2021-02-24 18:50:39 -05:00
parent 867074d81b
commit 1bc5c68c3f
4 changed files with 38 additions and 56 deletions

View File

@@ -103,9 +103,9 @@ func do(req *gemini.Request, via []*gemini.Request) (*gemini.Response, error) {
return resp, err
}
switch resp.Status().Class() {
switch resp.Status.Class() {
case gemini.StatusInput:
input, ok := getInput(resp.Meta(), resp.Status() == gemini.StatusSensitiveInput)
input, ok := getInput(resp.Meta, resp.Status == gemini.StatusSensitiveInput)
if !ok {
break
}
@@ -119,7 +119,7 @@ func do(req *gemini.Request, via []*gemini.Request) (*gemini.Response, error) {
return resp, errors.New("too many redirects")
}
target, err := url.Parse(resp.Meta())
target, err := url.Parse(resp.Meta)
if err != nil {
return resp, err
}
@@ -156,13 +156,13 @@ func main() {
defer resp.Close()
// Handle response
if resp.Status().Class() == gemini.StatusSuccess {
if resp.Status.Class() == gemini.StatusSuccess {
_, err := io.Copy(os.Stdout, resp)
if err != nil {
log.Fatal(err)
}
} else {
fmt.Printf("%d %s\n", resp.Status(), resp.Meta())
fmt.Printf("%d %s\n", resp.Status, resp.Meta)
os.Exit(1)
}
}