1
0
mirror of https://github.com/makew0rld/amfora.git synced 2024-09-27 23:05:55 -04:00
amfora/client/client.go
2020-06-21 20:37:27 -04:00

25 lines
515 B
Go

// Package client retrieves data over Gemini and implements a TOFU system.
package client
import (
"net/url"
"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(u string) (*gemini.Response, error) {
resp, err := gemini.Fetch(u)
if err != nil {
return nil, err
}
parsed, _ := url.Parse(u)
ok := handleTofu(resp.Cert, parsed.Port())
if !ok {
return resp, ErrTofu
}
return resp, err
}