👷 Only show client warning once everytime

pull/1212/head
Kiyon 2021-03-10 15:09:50 +08:00
parent cdd642444d
commit ef8f1ddaa3
1 changed files with 6 additions and 4 deletions

View File

@ -16,9 +16,8 @@ import (
"sync" "sync"
"time" "time"
"github.com/gofiber/fiber/v2/utils"
"github.com/gofiber/fiber/v2/internal/encoding/json" "github.com/gofiber/fiber/v2/internal/encoding/json"
"github.com/gofiber/fiber/v2/utils"
"github.com/valyala/fasthttp" "github.com/valyala/fasthttp"
) )
@ -480,7 +479,7 @@ func (a *Agent) JSON(v interface{}) *Agent {
return a return a
} }
// XML sends a XML request. // XML sends an XML request.
func (a *Agent) XML(v interface{}) *Agent { func (a *Agent) XML(v interface{}) *Agent {
a.req.Header.SetContentType(MIMEApplicationXML) a.req.Header.SetContentType(MIMEApplicationXML)
@ -720,10 +719,13 @@ func (a *Agent) Dest(dest []byte) *Agent {
} }
/************************** End Agent Setting **************************/ /************************** End Agent Setting **************************/
var warnOnce sync.Once
// Bytes returns the status code, bytes body and errors of url. // Bytes returns the status code, bytes body and errors of url.
func (a *Agent) Bytes() (code int, body []byte, errs []error) { func (a *Agent) Bytes() (code int, body []byte, errs []error) {
warnOnce.Do(func() {
fmt.Println("[Warning] client is still in beta, API might change in the future!") fmt.Println("[Warning] client is still in beta, API might change in the future!")
})
defer a.release() defer a.release()