doc: used correct http.Client

Signed-off-by: SoXX <soxx@fenpa.ws>
This commit is contained in:
SoXX 2023-10-23 08:56:14 +02:00
parent fca7cdbd2b
commit 84e344e34d
12 changed files with 29 additions and 28 deletions

View File

@ -19,7 +19,7 @@ func main() {
// Log: Getting favorites from the API. // Log: Getting favorites from the API.
log.Println("Getting favorites API user: ") log.Println("Getting favorites API user: ")
// Initialize an HTTP client. // Initialize an http.Client.
client := http.Client{} client := http.Client{}
// Define query parameters for retrieving favorites. // Define query parameters for retrieving favorites.

View File

@ -19,7 +19,7 @@ func main() {
// Log: Getting a single note. // Log: Getting a single note.
log.Println("Getting single note: ") log.Println("Getting single note: ")
// Initialize an HTTP client. // Initialize an http.Client.
client := http.Client{} client := http.Client{}
// Specify the note ID for retrieval. // Specify the note ID for retrieval.

View File

@ -19,7 +19,7 @@ func main() {
// Log: Getting a single pool. // Log: Getting a single pool.
log.Println("Getting single pool: ") log.Println("Getting single pool: ")
// Initialize an HTTP client. // Initialize an http.Client.
client := http.Client{} client := http.Client{}
// Specify the pool ID for retrieval. // Specify the pool ID for retrieval.

View File

@ -19,7 +19,7 @@ func main() {
// Log: Getting a single post. // Log: Getting a single post.
log.Println("Getting single post: ") log.Println("Getting single post: ")
// Initialize an HTTP client. // Initialize an http.Client.
client := http.Client{} client := http.Client{}
// Specify the post ID for retrieval. // Specify the post ID for retrieval.

View File

@ -19,7 +19,7 @@ func main() {
// Log: Getting a single tag. // Log: Getting a single tag.
log.Println("Getting a single tag: ") log.Println("Getting a single tag: ")
// Initialize an HTTP client. // Initialize an http.Client.
client := http.Client{} client := http.Client{}
// Specify the tag ID for retrieval. // Specify the tag ID for retrieval.

View File

@ -19,7 +19,7 @@ func main() {
// Log: Getting a single user. // Log: Getting a single user.
log.Println("Getting a single user: ") log.Println("Getting a single user: ")
// Initialize an HTTP client. // Initialize an http.Client.
client := http.Client{} client := http.Client{}
// Specify the username for retrieval. // Specify the username for retrieval.

View File

@ -14,7 +14,7 @@ import (
// The user_id parameter is required to get the favorites of a user. // The user_id parameter is required to get the favorites of a user.
// //
// Parameters: // Parameters:
// - client: An HTTP client used to make the API request. // - client: An http.Client used to make the API request.
// - requestContext: The context for the API request, including the host, user agent, username, and API key. // - requestContext: The context for the API request, including the host, user agent, username, and API key.
// - query: A map containing additional query parameters for the API request. // - query: A map containing additional query parameters for the API request.
// //
@ -39,7 +39,7 @@ func GetFavorites(client http.Client, requestContext model.RequestContext, query
r.Header.Add("Accept", "application/json") r.Header.Add("Accept", "application/json")
r.SetBasicAuth(requestContext.Username, requestContext.APIKey) r.SetBasicAuth(requestContext.Username, requestContext.APIKey)
// Send the request using the provided HTTP client. // Send the request using the provided http.Client.
resp, err := client.Do(r) resp, err := client.Do(r)
if err != nil { if err != nil {
log.Print(err) log.Print(err)

View File

@ -12,7 +12,7 @@ import (
// GetNote retrieves a single note by its ID from the e621 API. // GetNote retrieves a single note by its ID from the e621 API.
// //
// Parameters: // Parameters:
// - client: An HTTP client used to make the API request. // - client: An http.Client used to make the API request.
// - requestContext: The context for the API request, including the host, user agent, username, and API key. // - requestContext: The context for the API request, including the host, user agent, username, and API key.
// - ID: The ID of the note to retrieve. // - ID: The ID of the note to retrieve.
// //
@ -32,7 +32,7 @@ func GetNote(client http.Client, requestContext model.RequestContext, ID string)
r.Header.Add("Accept", "application/json") r.Header.Add("Accept", "application/json")
r.SetBasicAuth(requestContext.Username, requestContext.APIKey) r.SetBasicAuth(requestContext.Username, requestContext.APIKey)
// Send the request using the provided HTTP client. // Send the request using the provided http.Client.
resp, err := client.Do(r) resp, err := client.Do(r)
if err != nil { if err != nil {
// Log the error and return an empty Note struct and the error. // Log the error and return an empty Note struct and the error.
@ -64,7 +64,7 @@ func GetNote(client http.Client, requestContext model.RequestContext, ID string)
// GetNotes retrieves a list of notes from the e621 API based on query parameters. // GetNotes retrieves a list of notes from the e621 API based on query parameters.
// //
// Parameters: // Parameters:
// - client: An HTTP client used to make the API request. // - client: An http.Client used to make the API request.
// - requestContext: The context for the API request, including the host, user agent, username, and API key. // - requestContext: The context for the API request, including the host, user agent, username, and API key.
// - query: A map containing additional query parameters for the API request. // - query: A map containing additional query parameters for the API request.
// //
@ -89,7 +89,7 @@ func GetNotes(client http.Client, requestContext model.RequestContext, query map
r.Header.Add("Accept", "application/json") r.Header.Add("Accept", "application/json")
r.SetBasicAuth(requestContext.Username, requestContext.APIKey) r.SetBasicAuth(requestContext.Username, requestContext.APIKey)
// Send the request using the provided HTTP client. // Send the request using the provided http.Client.
resp, err := client.Do(r) resp, err := client.Do(r)
if err != nil { if err != nil {
log.Print(err) log.Print(err)

View File

@ -12,7 +12,7 @@ import (
// GetPool retrieves a pool by its ID from the e621 API. // GetPool retrieves a pool by its ID from the e621 API.
// //
// Parameters: // Parameters:
// - client: An HTTP client used to make the API request. // - client: An http.Client used to make the API request.
// - requestContext: The context for the API request, including the host, user agent, username, and API key. // - requestContext: The context for the API request, including the host, user agent, username, and API key.
// - ID: The ID of the pool to retrieve. // - ID: The ID of the pool to retrieve.
// //
@ -32,7 +32,7 @@ func GetPool(client http.Client, requestContext model.RequestContext, ID string)
r.Header.Add("Accept", "application/json") r.Header.Add("Accept", "application/json")
r.SetBasicAuth(requestContext.Username, requestContext.APIKey) r.SetBasicAuth(requestContext.Username, requestContext.APIKey)
// Send the request using the provided HTTP client. // Send the request using the provided http.Client.
resp, err := client.Do(r) resp, err := client.Do(r)
if err != nil { if err != nil {
// Log the error and return an empty Pool struct and the error. // Log the error and return an empty Pool struct and the error.
@ -64,7 +64,7 @@ func GetPool(client http.Client, requestContext model.RequestContext, ID string)
// GetPools retrieves a list of pools from the e621 API based on query parameters. // GetPools retrieves a list of pools from the e621 API based on query parameters.
// //
// Parameters: // Parameters:
// - client: An HTTP client used to make the API request. // - client: An http.Client used to make the API request.
// - requestContext: The context for the API request, including the host, user agent, username, and API key. // - requestContext: The context for the API request, including the host, user agent, username, and API key.
// - query: A map containing additional query parameters for the API request. // - query: A map containing additional query parameters for the API request.
// //
@ -89,7 +89,7 @@ func GetPools(client http.Client, requestContext model.RequestContext, query map
r.Header.Add("Accept", "application/json") r.Header.Add("Accept", "application/json")
r.SetBasicAuth(requestContext.Username, requestContext.APIKey) r.SetBasicAuth(requestContext.Username, requestContext.APIKey)
// Send the request using the provided HTTP client. // Send the request using the provided http.Client.
resp, err := client.Do(r) resp, err := client.Do(r)
if err != nil { if err != nil {
log.Print(err) log.Print(err)

View File

@ -12,7 +12,7 @@ import (
// GetPost retrieves a single post by its ID from the e621 API. // GetPost retrieves a single post by its ID from the e621 API.
// //
// Parameters: // Parameters:
// - client: An HTTP client used to make the API request. // - client: An http.Client used to make the API request.
// - requestContext: The context for the API request, including the host, user agent, username, and API key. // - requestContext: The context for the API request, including the host, user agent, username, and API key.
// - ID: The ID of the post to retrieve. // - ID: The ID of the post to retrieve.
// //
@ -32,7 +32,7 @@ func GetPost(client http.Client, requestContext model.RequestContext, ID string)
r.Header.Add("Accept", "application/json") r.Header.Add("Accept", "application/json")
r.SetBasicAuth(requestContext.Username, requestContext.APIKey) r.SetBasicAuth(requestContext.Username, requestContext.APIKey)
// Send the request using the provided HTTP client. // Send the request using the provided http.Client.
resp, err := client.Do(r) resp, err := client.Do(r)
if err != nil { if err != nil {
// Log the error and return an empty Post struct and the error. // Log the error and return an empty Post struct and the error.
@ -64,7 +64,7 @@ func GetPost(client http.Client, requestContext model.RequestContext, ID string)
// GetPosts retrieves a list of posts from the e621 API based on query parameters. // GetPosts retrieves a list of posts from the e621 API based on query parameters.
// //
// Parameters: // Parameters:
// - client: An HTTP client used to make the API request. // - client: An http.Client used to make the API request.
// - requestContext: The context for the API request, including the host, user agent, username, and API key. // - requestContext: The context for the API request, including the host, user agent, username, and API key.
// - query: A map containing additional query parameters for the API request. // - query: A map containing additional query parameters for the API request.
// //
@ -89,7 +89,7 @@ func GetPosts(client http.Client, requestContext model.RequestContext, query map
r.Header.Add("Accept", "application/json") r.Header.Add("Accept", "application/json")
r.SetBasicAuth(requestContext.Username, requestContext.APIKey) r.SetBasicAuth(requestContext.Username, requestContext.APIKey)
// Send the request using the provided HTTP client. // Send the request using the provided http.Client.
resp, err := client.Do(r) resp, err := client.Do(r)
if err != nil { if err != nil {
log.Print(err) log.Print(err)

View File

@ -12,7 +12,7 @@ import (
// GetTag retrieves a tag by its ID from the e621 API. // GetTag retrieves a tag by its ID from the e621 API.
// //
// Parameters: // Parameters:
// - client: An HTTP client used to make the API request. // - client: An http.Client used to make the API request.
// - requestContext: The context for the API request, including the host, user agent, username, and API key. // - requestContext: The context for the API request, including the host, user agent, username, and API key.
// - ID: The ID of the tag to retrieve. // - ID: The ID of the tag to retrieve.
// //
@ -32,7 +32,7 @@ func GetTag(client http.Client, requestContext model.RequestContext, ID string)
r.Header.Add("Accept", "application.json") r.Header.Add("Accept", "application.json")
r.SetBasicAuth(requestContext.Username, requestContext.APIKey) r.SetBasicAuth(requestContext.Username, requestContext.APIKey)
// Send the request using the provided HTTP client. // Send the request using the provided http.Client.
resp, err := client.Do(r) resp, err := client.Do(r)
if err != nil { if err != nil {
// Log the error and return an empty Tag struct and the error. // Log the error and return an empty Tag struct and the error.
@ -59,12 +59,13 @@ func GetTag(client http.Client, requestContext model.RequestContext, ID string)
// Return the tag information and no error (nil). // Return the tag information and no error (nil).
return tag, nil return tag, nil
} }
// GetTags retrieves a list of tags from the e621 API based on query parameters. // GetTags retrieves a list of tags from the e621 API based on query parameters.
// //
// Parameters: // Parameters:
// - client: An HTTP client used to make the API request. // - client: An http.Client used to make the API request.
// - requestContext: The context for the API request, including the host, user agent, username, and API key. // - requestContext: The context for the API request, including the host, user agent, username, and API key.
// - query: A map containing additional query parameters for the API request. // - query: A map containing additional query parameters for the API request.
// //
@ -99,7 +100,7 @@ func GetTags(client http.Client, requestContext model.RequestContext, query map[
r.Header.Add("Accept", "application/json") r.Header.Add("Accept", "application/json")
r.SetBasicAuth(requestContext.Username, requestContext.APIKey) r.SetBasicAuth(requestContext.Username, requestContext.APIKey)
// Send the request using the provided HTTP client. // Send the request using the provided http.Client.
resp, err := client.Do(r) resp, err := client.Do(r)
if err != nil { if err != nil {
log.Print(err) log.Print(err)

View File

@ -12,7 +12,7 @@ import (
// GetUser retrieves user information from e621.net based on the provided username. // GetUser retrieves user information from e621.net based on the provided username.
// //
// Parameters: // Parameters:
// - client: An HTTP client used to make the API request. // - client: An http.Client used to make the API request.
// - requestContext: The context for the API request, including the host, user agent, username, and API key. // - requestContext: The context for the API request, including the host, user agent, username, and API key.
// - username: The username of the user to retrieve. // - username: The username of the user to retrieve.
// //
@ -32,7 +32,7 @@ func GetUser(client http.Client, requestContext model.RequestContext, username s
r.Header.Add("Accept", "application/json") r.Header.Add("Accept", "application/json")
r.SetBasicAuth(requestContext.Username, requestContext.APIKey) r.SetBasicAuth(requestContext.Username, requestContext.APIKey)
// Send the request using the provided HTTP client. // Send the request using the provided http.Client.
resp, err := client.Do(r) resp, err := client.Do(r)
if err != nil { if err != nil {
// Log the error and return an empty User struct and the error. // Log the error and return an empty User struct and the error.
@ -64,7 +64,7 @@ func GetUser(client http.Client, requestContext model.RequestContext, username s
// GetUsers retrieves a list of users from e621.net based on query parameters. // GetUsers retrieves a list of users from e621.net based on query parameters.
// //
// Parameters: // Parameters:
// - client: An HTTP client used to make the API request. // - client: An http.Client used to make the API request.
// - requestContext: The context for the API request, including the host, user agent, username, and API key. // - requestContext: The context for the API request, including the host, user agent, username, and API key.
// - query: A map containing additional query parameters for the API request. // - query: A map containing additional query parameters for the API request.
// //
@ -89,7 +89,7 @@ func GetUsers(client http.Client, requestContext model.RequestContext, query map
r.Header.Add("Accept", "application/json") r.Header.Add("Accept", "application/json")
r.SetBasicAuth(requestContext.Username, requestContext.APIKey) r.SetBasicAuth(requestContext.Username, requestContext.APIKey)
// Send the request using the provided HTTP client. // Send the request using the provided http.Client.
resp, err := client.Do(r) resp, err := client.Do(r)
if err != nil { if err != nil {
log.Print(err) log.Print(err)