### Install Fast Shot Go Package Source: https://github.com/opus-domini/fast-shot/blob/main/docs/README.md Command to install the Fast Shot Go package using the go get command. ```Bash go get github.com/opus-domini/fast-shot ``` -------------------------------- ### Install Fast Shot Go Library Source: https://github.com/opus-domini/fast-shot/blob/main/README.md Installs the Fast Shot Go library using the go get command. This is the standard way to add external packages to your Go project. ```Bash go get github.com/opus-domini/fast-shot ``` -------------------------------- ### Fast Shot Quick Start POST Request Source: https://github.com/opus-domini/fast-shot/blob/main/README.md Demonstrates a basic POST request using Fast Shot. It shows how to create a client, set authentication, add headers, send a JSON payload, and handle the response. ```Go package main import ( "fmt" fastshot "github.com/opus-domini/fast-shot" "github.com/opus-domini/fast-shot/constant/mime" ) func main() { client := fastshot.NewClient("https://api.example.com"). Auth().BearerToken("your_token_here"). Build() payload := map[string]interface{}{ "key1": "value1", "key2": "value2", } response, err := client.POST("/endpoint"). Header().AddAccept(mime.JSON). Body().AsJSON(payload). Send() // Check for request send problems. if err != nil { panic(err) // (¬_¬") } // Check for (4xx || 5xx) errors response. if response.Status().IsError() { panic(response.Body().AsString()) // ¯\_(ツ)_/¯ } var result map[string]interface{} _ := response.Body().AsJSON(&result) // Congrats! Do something awesome with the result (¬‿¬) } ``` -------------------------------- ### Basic POST Request with Fast Shot Source: https://github.com/opus-domini/fast-shot/blob/main/docs/README.md Example of making a POST request using Fast Shot, including setting bearer token authentication, accept header, and sending a JSON payload. It also demonstrates error handling for request sending and response status. ```Go package main import ( "fmt" fastshot "github.com/opus-domini/fast-shot" "github.com/opus-domini/fast-shot/constant/mime" ) func main() { client := fastshot.NewClient("https://api.example.com"). Auth().BearerToken("your_token_here"). Build() payload := map[string]interface{}{ "key1": "value1", "key2": "value2", } response, err := client.POST("/endpoint"). Header().AddAccept(mime.JSON). Body().AsJSON(payload). Send() // Check for request send problems. if err != nil { panic(err) // (¬_¬") } // Check for (4xx || 5xx) errors response. if response.Status().IsError() { panic(response.Body().AsString()) // ¯\_(ツ)_/¯ } var result map[string]interface{} _ := response.Body().AsJSON(&result) // Congrats! Do something awesome with the result (¬‿¬) } ``` -------------------------------- ### Clone Fast Shot Repository Source: https://github.com/opus-domini/fast-shot/blob/main/CONTRIBUTING.md Instructions for cloning your forked repository of Fast Shot using Git. This is the first step after forking the project to start making changes. ```bash git clone git@github.com:/fast-shot.git ``` -------------------------------- ### Fast Shot Advanced Retry Mechanism Source: https://github.com/opus-domini/fast-shot/blob/main/docs/README.md Example of configuring an exponential backoff retry strategy for HTTP requests using Fast Shot, including setting initial delay, count, and multiplier. ```Go client.POST("/resource"). Retry().SetExponentialBackoff(2 * time.Second, 5, 2.0). Send() ``` -------------------------------- ### Docsify Configuration for Fast-Shot Source: https://github.com/opus-domini/fast-shot/blob/main/docs/index.html This snippet shows the global configuration for Docsify, setting the project name and linking to the GitHub repository. It's a common pattern for initializing Docsify-based documentation sites. ```javascript window.$docsify = { name: 'Fast-Shot', repo: 'https://github.com/opus-domini/fast-shot.git' } ``` -------------------------------- ### Fast Shot Fluent API Chaining Source: https://github.com/opus-domini/fast-shot/blob/main/docs/README.md Demonstrates chaining multiple configurations like authentication, headers, and timeouts in a single line using Fast Shot's fluent API. ```Go client := fastshot.NewClient("https://api.example.com"). Auth().BearerToken("your-bearer-token"). Header().Add("My-Header", "My-Value"). Config().SetTimeout(30 * time.Second). Build() ``` -------------------------------- ### Fast Shot Advanced API Chaining Source: https://github.com/opus-domini/fast-shot/blob/main/README.md Illustrates the fluent and chainable API of Fast Shot, allowing multiple client configurations to be set in a single, readable line. ```Go client := fastshot.NewClient("https://api.example.com"). Auth().BearerToken("your-bearer-token"). Header().Add("My-Header", "My-Value"). Config().SetTimeout(30 * time.Second). Build() ``` -------------------------------- ### Fast Shot Advanced Client Configurations Source: https://github.com/opus-domini/fast-shot/blob/main/README.md Details advanced configuration options for the Fast Shot HTTP client, such as setting timeouts, controlling redirects, using custom transports, and configuring proxies. ```go // Set Timeout builder.Config(). SetTimeout(time.Second * 30) // Set Follow Redirect builder.Config(). SetFollowRedirects(false) // Set Custom Transport builder.Config(). SetCustomTransport(myCustomTransport) // Set Proxy builder.Config(). SetProxy("http://my-proxy-server:port") ``` -------------------------------- ### Fast Shot Client-Side Load Balancing Source: https://github.com/opus-domini/fast-shot/blob/main/docs/README.md Shows how to initialize Fast Shot with multiple API endpoints for client-side load balancing, along with setting a timeout for the client. ```Go client := fastshot.NewClientLoadBalancer([]string{ "https://api1.example.com", "https://api2.example.com", "https://api3.example.com", }). Config().SetTimeout(time.Second * 10). Build() ``` -------------------------------- ### Fast Shot Authentication Methods Source: https://github.com/opus-domini/fast-shot/blob/main/README.md Demonstrates how to configure different authentication methods for the Fast Shot HTTP client, including Bearer Token, Basic Authentication, and custom headers. ```go // Bearer Token builder.Auth().BearerToken("your-bearer-token") // Basic Authentication builder.Auth().BasicAuth("username", "password") // Custom Authentication builder.Auth().Set("custom-authentication-header") ``` -------------------------------- ### Fast Shot Client Load Balancing Source: https://github.com/opus-domini/fast-shot/blob/main/README.md Shows how to set up Fast Shot to use client-side load balancing across multiple API endpoints for improved reliability and performance. ```Go client := fastshot.NewClientLoadBalancer([]string{ "https://api1.example.com", "https://api2.example.com", "https://api3.example.com", }). Config().SetTimeout(time.Second * 10). Build() ``` -------------------------------- ### Fast Shot Authentication Methods Source: https://github.com/opus-domini/fast-shot/blob/main/docs/README.md Demonstrates how to configure different authentication methods for the Fast Shot HTTP client, including Bearer Token, Basic Authentication, and custom headers. ```go // Bearer Token builder.Auth().BearerToken("your-bearer-token") // Basic Authentication builder.Auth().BasicAuth("username", "password") // Custom Authentication builder.Auth().Set("custom-authentication-header") ``` -------------------------------- ### Fast Shot Advanced Client Configurations Source: https://github.com/opus-domini/fast-shot/blob/main/docs/README.md Details advanced configuration options for the Fast Shot HTTP client, such as setting timeouts, controlling redirects, using custom transports, and configuring proxies. ```go // Set Timeout builder.Config(). SetTimeout(time.Second * 30) // Set Follow Redirect builder.Config(). SetFollowRedirects(false) // Set Custom Transport builder.Config(). SetCustomTransport(myCustomTransport) // Set Proxy builder.Config(). SetProxy("http://my-proxy-server:port") ``` -------------------------------- ### Fast Shot Response Handling Source: https://github.com/opus-domini/fast-shot/blob/main/README.md Explains how to access and process responses received from HTTP requests made with the Fast Shot client, including status checks, body access, headers, cookies, and raw response retrieval. ```go // Fluent response status check response.Status() // Easy response body access and conversion response.Body() // Get response headers to inspect response.Header() // Get response cookies for further processing response.Cookie() // Get raw response if needed response.Raw() // and more... ``` -------------------------------- ### Go Code Formatting Source: https://github.com/opus-domini/fast-shot/blob/main/CONTRIBUTING.md Information on adhering to Go's standard code formatting conventions using the `gofmt` tool. This ensures code consistency and readability. ```go # Follow the standard Go formatting conventions. You can use the `gofmt` tool for automatic formatting. ``` -------------------------------- ### Fast Shot Response Handling Source: https://github.com/opus-domini/fast-shot/blob/main/docs/README.md Explains how to access and process responses received from HTTP requests made with the Fast Shot client, including status checks, body access, headers, cookies, and raw response retrieval. ```go // Fluent response status check response.Status() // Easy response body access and conversion response.Body() // Get response headers to inspect response.Header() // Get response cookies for further processing response.Cookie() // Get raw response if needed response.Raw() // and more... ``` -------------------------------- ### Fast Shot Custom Headers and Cookies Source: https://github.com/opus-domini/fast-shot/blob/main/README.md Shows how to add custom headers and cookies to requests using the Fast Shot client. Supports adding single headers, multiple headers, and HTTP cookies. ```go // Add Custom Header builder.Header(). Add("header", "value") // Add Multiple Custom Headers builder.Header(). AddAll(map[string]string{ "key1": "value1", "key2": "value2", "key3": "value3", }) // Add Custom Cookie builder.Cookie(). Add(&http.Cookie{Name: "session_id", Value: "id"}) ``` -------------------------------- ### Fast Shot Custom Headers and Cookies Source: https://github.com/opus-domini/fast-shot/blob/main/docs/README.md Shows how to add custom headers and cookies to requests using the Fast Shot client. Supports adding single headers, multiple headers, and HTTP cookies. ```go // Add Custom Header builder.Header(). Add("header", "value") // Add Multiple Custom Headers builder.Header(). AddAll(map[string]string{ "key1": "value1", "key2": "value2", "key3": "value3", }) // Add Custom Cookie builder.Cookie(). Add(&http.Cookie{Name: "session_id", Value: "id"}) ``` -------------------------------- ### Fast Shot Advanced Retry Mechanism Source: https://github.com/opus-domini/fast-shot/blob/main/README.md Demonstrates how to configure an advanced retry mechanism with exponential backoff for HTTP requests using Fast Shot. It supports various backoff strategies and jitter. ```Go client.POST("/resource"). Retry().SetExponentialBackoff(2 * time.Second, 5, 2.0). Send() ``` -------------------------------- ### Create New Branch Source: https://github.com/opus-domini/fast-shot/blob/main/CONTRIBUTING.md Command to create a new Git branch for your feature or bug fix. Using descriptive branch names is recommended for clarity. ```bash git checkout -b my-new-feature ``` -------------------------------- ### Push Changes to Remote Source: https://github.com/opus-domini/fast-shot/blob/main/CONTRIBUTING.md Command to push your local branch with committed changes to the remote repository. This makes your changes available for pull requests. ```bash git push origin my-new-feature ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.