amfora/client/client.go

21 lines
463 B
Go
Raw Normal View History

2020-06-18 23:54:48 +03:00
// Package client retrieves data over Gemini and implements a TOFU system.
package client
import (
"github.com/makeworld-the-better-one/go-gemini"
)
// Fetch returns response data and an error.
// The error text is human friendly and should be displayed.
func Fetch(url string) (*gemini.Response, error) {
resp, err := gemini.Fetch(url)
if err != nil {
2020-06-19 21:05:05 +03:00
return nil, err
2020-06-18 23:54:48 +03:00
}
ok := handleTofu(resp.Cert)
if !ok {
return nil, ErrTofu
}
return resp, err
}