package httpximport ()// Auth sets the Authorization header using a scheme and token.// @group Auth// Applies to both client defaults and request-time overrides.//// Example: custom auth scheme//// // Apply to all requests// c := httpx.New(httpx.Auth("Token", "abc123"))// httpx.Get[string](c, "https://example.com")//// // Apply to a single request// httpx.Get[string](httpx.Default(), "https://example.com", httpx.Auth("Token", "abc123"))func (, string) OptionBuilder {returnOptionBuilder{}.Auth(, )}func ( OptionBuilder) (, string) OptionBuilder { := + " " + return .add(bothOption(func( *Client) { .req.SetCommonHeader("Authorization", ) },func( *req.Request) { .SetHeader("Authorization", ) }, ))}// Bearer sets the Authorization header with a bearer token.// @group Auth// Applies to both client defaults and request-time overrides.//// Example: bearer auth//// // Apply to all requests// c := httpx.New(httpx.Bearer("token"))// httpx.Get[string](c, "https://example.com")//// // Apply to a single request// httpx.Get[string](httpx.Default(), "https://example.com", httpx.Bearer("token"))func ( string) OptionBuilder {returnOptionBuilder{}.Bearer()}func ( OptionBuilder) ( string) OptionBuilder { := "Bearer " + return .add(bothOption(func( *Client) { .req.SetCommonHeader("Authorization", ) },func( *req.Request) { .SetBearerAuthToken() }, ))}// Basic sets HTTP basic authentication headers.// @group Auth// Applies to both client defaults and request-time overrides.//// Example: basic auth//// // Apply to all requests// c := httpx.New(httpx.Basic("user", "pass"))// httpx.Get[string](c, "https://example.com")//// // Apply to a single request// httpx.Get[string](httpx.Default(), "https://example.com", httpx.Basic("user", "pass"))func (, string) OptionBuilder {returnOptionBuilder{}.Basic(, )}func ( OptionBuilder) (, string) OptionBuilder { := "Basic " + base64.StdEncoding.EncodeToString([]byte(+":"+))return .add(bothOption(func( *Client) { .req.SetCommonHeader("Authorization", ) },func( *req.Request) { .SetBasicAuth(, ) }, ))}
The pages are generated with Goldsv0.8.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.