utils

package
v1.0.8 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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, secretName string) ([]byte, error)

GetSecretValue is a function to retrieve a key value from Google Cloud Secret Manager.

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