utils

package
v1.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2023 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateEmptyPool added in v1.1.0

func CreateEmptyPool(maxWorkers int) *pool

CreateEmptyPool creates a new worker pool with the specified maximum number of workers. It returns a pointer to the created Pool.

func GetComponent

func GetComponent() string

GetComponent returns details about the caller function. It is utilized to populate the component field of a GoogleLogEntry, or any other log entry component field.

func GetFirebaseIDToken

func GetFirebaseIDToken(email, password, firebaseAPIKey string) (string, error)

GetFirebaseIDToken exchanges an email and password for a Firebase ID token. The email and password are used to authenticate with Firebase. The Firebase ID token is returned. If the request fails, an error is returned.

func GetSecretValue added in v1.0.8

func GetSecretValue(FS embed.FS, credentialsPath string, projectID string, secretID string, versionID string) ([]byte, error)

GetSecretValue is a function to retrieve a secret value from Google Cloud Secret Manager. FS is the embed.FS embedded filesystem to pass to the function. The credentialsPath parameter is the path to the credentials file. The projectID parameter is the ID of the Google Cloud project. The secretID parameter is the ID of the secret. The versionID parameter is the ID of the secret version. The secret value is returned as a byte slice.

func WriteErrorResponse added in v1.0.7

func WriteErrorResponse(w http.ResponseWriter, msg string, errorCode int)

WriteErrorResponse writes an error response to the response writer with appropriate headers. It does NOT return an error because it is used to write an error response. Instead, if an error occurs internally, it writes the error to the response writer with http.Error.

func WriteGzipJSONResponse

func WriteGzipJSONResponse(w http.ResponseWriter, data interface{}, code int) error

WriteGzippedJSONResponse compresses the JSON data and writes it to the response writer with appropriate headers. The Content-Encoding header is set to gzip and the Content-Type header is set to application/json. The Content-Length header is set with the length of the compressed data. The status code is set based on the provided code parameter. If the data cannot be serialized to JSON, an error is returned. If the compressed data cannot be written to the response writer, an error is returned.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL