utils
Index
- func ArrContains[T constraints.Ordered](arr []T, obj T) bool
- func ArrContainsArr[T constraints.Ordered](arr []T, subArr []T) bool
- func GetCred(value string) (string, error)
- func GetCredUnsafe(value string) string
- func MakeAPIRequest(client *http.Client, kind, apiBaseURL, endpoint, token string, request, response interface{}) error
- func MakeDeleteRequest(client *http.Client, apiBaseURL, endpoint, token string, response interface{}) error
- func MakeGetRequest(client *http.Client, apiBaseURL, endpoint, token string, response interface{}) error
- func MakePostRequest(client *http.Client, apiBaseURL, endpoint, token string, request, response interface{}) error
- func MakePutRequest(client *http.Client, apiBaseURL, endpoint, token string, request, response interface{}) error
- func RunAPIServer(port int) error
- type APIError
- func (e *APIError) Error() string
- type AuthenticatedAPIClient
- func NewAPIClient(baseURL, token string) AuthenticatedAPIClient
- func (c *AuthenticatedAPIClient) Delete(endpoint string, response interface{}) error
- func (c *AuthenticatedAPIClient) Get(endpoint string, response interface{}) error
- func (c *AuthenticatedAPIClient) Post(endpoint string, request, response interface{}) error
- func (c *AuthenticatedAPIClient) Put(endpoint string, request, response interface{}) error
- type DeveloperError
- func (e *DeveloperError) Error() string
- type GPTDoesntListenError
- func (e *GPTDoesntListenError) Error() string
- type NoCredFoundError
- func (e *NoCredFoundError) Error() string
func ArrContains
ArrContains checks if an array contains obj
func ArrContainsArr
ArrContainsArr checks if an array contains all elements of another array
func GetCred
GetCred is a function that gets a credential from the environment variables. If the credential is not found, it will return an error.
func GetCredUnsafe
GetCredUnsafe is a function that gets a credential from the environment variables. If the credential is not found, it will log a fatal error.
func MakeAPIRequest
func MakeAPIRequest(client *http.Client, kind, apiBaseURL, endpoint, token string, request, response interface{}) error
MakeAPIRequest is a generic function to make an API request. It supports GET, POST, PUT, and DELETE requests.
func MakeDeleteRequest
func MakeDeleteRequest(client *http.Client, apiBaseURL, endpoint, token string, response interface{}) error
MakeDeleteRequest is a helper function to make a DELETE request to the specified endpoint. If token is not "" it will be added to the request as a Bearer token.
func MakeGetRequest
func MakeGetRequest(client *http.Client, apiBaseURL, endpoint, token string, response interface{}) error
MakeGetRequest is a helper function to make a GET request to the specified endpoint. If token is not "" it will be added to the request as a Bearer token.
func MakePostRequest
func MakePostRequest(client *http.Client, apiBaseURL, endpoint, token string, request, response interface{}) error
MakePostRequest is a helper function to make a POST request to the specified endpoint. If token is not "" it will be added to the request as a Bearer token.
func MakePutRequest
func MakePutRequest(client *http.Client, apiBaseURL, endpoint, token string, request, response interface{}) error
MakePutRequest is a helper function to make a PUT request to the specified endpoint. If token is not "" it will be added to the request as a Bearer token.
func RunAPIServer
RunAPIServer attaches logging middleware to the default http server and starts it on the specified port.
type APIError
APIError is an error type that is returned when an API request fails.
func (*APIError) Error
type AuthenticatedAPIClient
AuthenticatedAPIClient is a struct that contains the base URL of the API and the token to use for requests.
func NewAPIClient
NewAPIClient creates a new AuthenticatedAPIClient with the specified base URL and token.
func (*AuthenticatedAPIClient) Delete
Delete is a helper function to make a DELETE request to the specified endpoint. If token is not "" it will be added to the request as a Bearer token.
func (*AuthenticatedAPIClient) Get
Get is a helper function to make a GET request to the specified endpoint. If token is not "" it will be added to the request as a Bearer token.
func (*AuthenticatedAPIClient) Post
Post is a helper function to make a POST request to the specified endpoint. If token is not "" it will be added to the request as a Bearer token.
func (*AuthenticatedAPIClient) Put
Put is a helper function to make a PUT request to the specified endpoint. If token is not "" it will be added to the request as a Bearer token.
type DeveloperError
DeveloperError represents an error that is caused by a developer mistake
func (*DeveloperError) Error
type GPTDoesntListenError
GPTDoesntListenError represents an error when GPT doesn't listen
func (*GPTDoesntListenError) Error
type NoCredFoundError
NoCredFoundError represents an error when no credentials are found
func (*NoCredFoundError) Error
Generated by gomarkdoc