1// Copyright (c) 2015-2019 Jeevanandam M (jeeva@myjeeva.com), All rights reserved.
2// resty source code and usage is governed by a MIT style
3// license that can be found in the LICENSE file.
4
5// Package resty provides Simple HTTP and REST client library for Go.
6package resty
7
8import (
9	"net"
10	"net/http"
11	"net/http/cookiejar"
12
13	"golang.org/x/net/publicsuffix"
14)
15
16// Version # of resty
17const Version = "2.1.0"
18
19// New method creates a new Resty client.
20func New() *Client {
21	cookieJar, _ := cookiejar.New(&cookiejar.Options{PublicSuffixList: publicsuffix.List})
22	return createClient(&http.Client{
23		Jar: cookieJar,
24	})
25}
26
27// NewWithClient method creates a new Resty client with given `http.Client`.
28func NewWithClient(hc *http.Client) *Client {
29	return createClient(hc)
30}
31
32// NewWithLocalAddr method creates a new Resty client with given Local Address
33// to dial from.
34func NewWithLocalAddr(localAddr net.Addr) *Client {
35	cookieJar, _ := cookiejar.New(&cookiejar.Options{PublicSuffixList: publicsuffix.List})
36	return createClient(&http.Client{
37		Jar:       cookieJar,
38		Transport: createTransport(localAddr),
39	})
40}
41