Compare commits
6 Commits
cdee211a66
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e2781cde50 | ||
|
|
fecb52d12c | ||
|
|
e95976a4db | ||
|
|
e496e76ee7 | ||
|
|
9560131870 | ||
|
|
9b20ffc450 |
@@ -14,6 +14,7 @@ const (
|
||||
HeaderOrigin = "Origin"
|
||||
HeaderReferer = "Referer"
|
||||
HeaderAcceptLanguage = "Accept-Language"
|
||||
HeaderAcceptEncoding = "Accept-Encoding"
|
||||
|
||||
ContentTypeJSON = "application/json; charset=utf-8"
|
||||
)
|
||||
|
||||
@@ -25,18 +25,18 @@ var (
|
||||
|
||||
func init() {
|
||||
defaultClient = New()
|
||||
defaultNoRedirectClient = New(WithNoRedirect())
|
||||
defaultNoRedirectClient = New(WithNoRedirect(), WithNoCheckStatus(true))
|
||||
}
|
||||
|
||||
func ReInitDefault(timeout time.Duration) {
|
||||
defaultClient = New(WithTimout(timeout))
|
||||
defaultNoRedirectClient = New(WithNoRedirect(), WithTimout(timeout))
|
||||
defaultNoRedirectClient = New(WithNoRedirect(), WithNoCheckStatus(true), WithTimout(timeout))
|
||||
|
||||
}
|
||||
|
||||
func ReInitDefaultOpt(opts ...ConfigOpt) {
|
||||
defaultClient = New(opts...)
|
||||
defaultNoRedirectClient = New(slices.Concat([]ConfigOpt{WithNoRedirect()}, opts)...)
|
||||
defaultNoRedirectClient = New(slices.Concat([]ConfigOpt{WithNoRedirect(), WithNoCheckStatus(true)}, opts)...)
|
||||
|
||||
}
|
||||
|
||||
@@ -221,6 +221,15 @@ func (r *Request) SetCookieMap(cookiesMap map[string]*http.Cookie) *Request {
|
||||
return r
|
||||
}
|
||||
|
||||
func (r *Request) SetHtmlHeaders() *Request {
|
||||
r.SetHeaders(map[string]string{
|
||||
HeaderAccept: AcceptHtml,
|
||||
HeaderAcceptLanguage: AcceptCNLanguage,
|
||||
HeaderAcceptEncoding: AcceptEncodingIdentity,
|
||||
})
|
||||
return r
|
||||
}
|
||||
|
||||
func (r *Request) SetHeaders(headers map[string]string) *Request {
|
||||
for k, v := range headers {
|
||||
r.SetHeader(k, v)
|
||||
|
||||
@@ -2,12 +2,12 @@ package consul
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/consul/api"
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/grpc/resolver"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
const schemeName = "consul"
|
||||
@@ -116,7 +116,7 @@ func (c *consulResolver) watchService() {
|
||||
if err != nil {
|
||||
defaultLog.Errorf("%s update service state err: %s", err, c.tgt.String())
|
||||
} else {
|
||||
defaultLog.Infof("%s update service num:%d (%s)", c.tgt.String(), len(addrs), strings.Join(addrs, ", "))
|
||||
//defaultLog.Infof("%s update service num:%d (%s)", c.tgt.String(), len(addrs), strings.Join(addrs, ", "))
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user