go-mstdn/api/v1/streaming/public/local/dial.go

47 lines
652 B
Go
Raw Normal View History

2024-08-06 22:49:22 +00:00
package local
import (
"net/http"
"net/url"
"github.com/reiver/go-httpsse"
)
func DialHost(host string) (Client, error) {
var urloc = url.URL{
Scheme:"https",
Host:host,
Path:Path,
}
2024-08-07 15:05:46 +00:00
sseclient, err := httpsse.DialURL(urloc.String())
if nil != err {
return nil, err
}
return &internalClient{
sseclient:sseclient,
}, nil
2024-08-06 22:49:22 +00:00
}
func Dial(req *http.Request) (Client, error) {
2024-08-07 17:47:47 +00:00
if nil == req {
return nil, errNilHTTPRequest
}
if nil == req.URL {
req.URL = new(url.URL)
}
req.URL.Path = Path
2024-08-07 15:05:46 +00:00
sseclient, err :=httpsse.Dial(req)
if nil != err {
return nil, err
}
return &internalClient{
sseclient:sseclient,
}, nil
2024-08-06 22:49:22 +00:00
}