Documentation ¶
Index ¶
- func AllowPatchUpdate(toUpdate, temporaryToCompare, currentDocument interface{}) error
- func AuthenticateOIDCToken(w http.ResponseWriter, r *http.Request, authTokenKey string, ...) (map[string]interface{}, error)
- func CreateEmptyPool(maxWorkers int) *pool
- func CreateOIDCToken(FS embed.FS, credentialsPath string, audience string) (*oauth2.Token, error)
- func GetComponent() string
- func GetFirebaseIDToken(email, password, firebaseAPIKey string) (string, error)
- func GetSecretValue(FS embed.FS, credentialsPath string, projectID string, secretID string, ...) ([]byte, error)
- func WriteErrorResponse(w http.ResponseWriter, msg string, errorCode int)
- func WriteGzipJSONResponse(w http.ResponseWriter, data interface{}, code int) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllowPatchUpdate ¶ added in v1.1.9
func AllowPatchUpdate(toUpdate, temporaryToCompare, currentDocument interface{}) error
AllowPatchUpdate uses a temporary struct to compare against the current struct and update the official struct with the values from the current struct. toUpdate is the data to be sent to the database. temporaryToCompare is the data where a check is performed to detect nil values. currentDocument is the data to be compared against. All parameters MUST be POINTERS to structs which are ALL THE SAME TYPE, or the function will return an error.
func AuthenticateOIDCToken ¶ added in v1.1.8
func AuthenticateOIDCToken(w http.ResponseWriter, r *http.Request, authTokenKey string, expectedAudience, expectedIssuer string) (map[string]interface{}, error)
AuthenticateOIDCToken verifies a JWT token's authenticity based on the provided audience and issuer. It returns a success response if the token is valid. It returns an error if the token is invalid or does not match the expected audience and issuer.
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 CreateOIDCToken ¶ added in v1.1.8
CreateOIDCToken creates an OIDC token with the given audience.
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 ¶
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.