Code refactoring for streams HandleFunc

This commit is contained in:
Alex X
2024-06-14 12:48:29 +03:00
parent 1ac9d54dab
commit ecfe802065
15 changed files with 53 additions and 93 deletions
+6 -2
View File
@@ -23,7 +23,7 @@ type Client struct {
send int
}
func NewClient(rawURL string) (*Client, error) {
func Dial(rawURL string) (*Client, error) {
// check if url is valid url
u, err := url.Parse(rawURL)
if err != nil {
@@ -33,7 +33,11 @@ func NewClient(rawURL string) (*Client, error) {
u.Scheme = "http"
u.Path = ""
return &Client{url: u.String()}, nil
client := &Client{url: u.String()}
if err = client.Dial(); err != nil {
return nil, err
}
return client, err
}
func (c *Client) Dial() (err error) {