MCPcopy
hub / github.com/gofiber/fiber / setConfigToRequest

Function setConfigToRequest

client/client.go:846–913  ·  view source on GitHub ↗

setConfigToRequest sets the parameters passed via Config to the Request.

(req *Request, config ...Config)

Source from the content-addressed store, hash-verified

844
845// setConfigToRequest sets the parameters passed via Config to the Request.
846func setConfigToRequest(req *Request, config ...Config) {
847 if len(config) == 0 {
848 return
849 }
850 cfg := config[0]
851
852 if cfg.Ctx != nil {
853 req.SetContext(cfg.Ctx)
854 }
855
856 if cfg.UserAgent != "" {
857 req.SetUserAgent(cfg.UserAgent)
858 }
859
860 if cfg.Referer != "" {
861 req.SetReferer(cfg.Referer)
862 }
863
864 if cfg.Header != nil {
865 req.SetHeaders(cfg.Header)
866 }
867
868 if cfg.Param != nil {
869 req.SetParams(cfg.Param)
870 }
871
872 if cfg.Cookie != nil {
873 req.SetCookies(cfg.Cookie)
874 }
875
876 if cfg.PathParam != nil {
877 req.SetPathParams(cfg.PathParam)
878 }
879
880 if cfg.Timeout != 0 {
881 req.SetTimeout(cfg.Timeout)
882 }
883
884 if cfg.MaxRedirects != 0 {
885 req.SetMaxRedirects(cfg.MaxRedirects)
886 }
887
888 if cfg.DisablePathNormalizing {
889 req.SetDisablePathNormalizing(true)
890 }
891
892 if cfg.Body != nil {
893 switch v := cfg.Body.(type) {
894 case []byte:
895 req.SetRawBody(v)
896 case string:
897 req.SetRawBody([]byte(v))
898 default:
899 req.SetJSON(cfg.Body)
900 }
901 return
902 }
903

Callers 10

GetMethod · 0.85
PostMethod · 0.85
HeadMethod · 0.85
PutMethod · 0.85
DeleteMethod · 0.85
OptionsMethod · 0.85
PatchMethod · 0.85
QueryMethod · 0.85
CustomMethod · 0.85

Calls 14

SetMaxRedirectsMethod · 0.80
SetRawBodyMethod · 0.80
SetFormDataWithMapMethod · 0.80
AddFilesMethod · 0.80
SetContextMethod · 0.65
SetUserAgentMethod · 0.45
SetRefererMethod · 0.45
SetHeadersMethod · 0.45
SetParamsMethod · 0.45
SetCookiesMethod · 0.45
SetPathParamsMethod · 0.45
SetTimeoutMethod · 0.45

Tested by 1