Documentation ¶
Index ¶
- Variables
- func FormatPrompt(s string) string
- func GetCountryCode(r *http.Request) string
- func GetDefaultServerUrl() string
- func GetEnv(key string, fallback string) string
- func GetImageSizeFromUrl(imageUrl string) (bytes int64, err error)
- func GetImageWidthHeightFromUrl(imageUrl string, maxSizeBytes int64) (width, height int32, err error)
- func IsSha256Hash(str string) bool
- func IsValidHTTPURL(urlStr string) bool
- func ParseIsoTime(isoTime string) (time.Time, error)
- func RelativeTimeStr(t time.Time) string
- func RemoveLineBreaks(s string) string
- func RemoveRedundantSpaces(s string) string
- func RootDir() string
- func Sha256(s string) string
- func TimeToIsoString(ts time.Time) string
- type ClientDeviceInfo
- type ClientDeviceType
- type S3Data
Constants ¶
This section is empty.
Variables ¶
var RuntimeCaller = runtime.Caller
Functions ¶
func FormatPrompt ¶
FormatPrompt applies formatting to a prompt string e.g. " hello world " -> "hello world"
func GetCountryCode ¶
Retrieves a country code via request header, prefer cloudflare, then vercel
func GetDefaultServerUrl ¶
func GetDefaultServerUrl() string
func GetImageSizeFromUrl ¶
Retrieves the download size of an image via headers
func IsSha256Hash ¶
func IsValidHTTPURL ¶
Validates that a URL is valid with http or https scheme
func ParseIsoTime ¶
Parse an iso string into a time.Time e.g. 2023-01-27T14:40:53.858Z represents javascript toISOString()
func RelativeTimeStr ¶
Create a relative time string from now to past (e.g., "1h ago")
func RemoveLineBreaks ¶
RemoveLineBreaks removes all line breaks from a string e.g. "hello\nworld" -> "hello world"
func RemoveRedundantSpaces ¶
RemoveRedundantSpaces removes all redundant spaces from a string e.g. " hello world " -> " hello world "
func TimeToIsoString ¶
Types ¶
type ClientDeviceInfo ¶
type ClientDeviceInfo struct { DeviceType ClientDeviceType DeviceOs string DeviceBrowser string }
func GetClientDeviceInfo ¶
func GetClientDeviceInfo(r *http.Request) ClientDeviceInfo
type ClientDeviceType ¶
type ClientDeviceType string
Parses user agent to return device type, os, and browser
const ( Desktop ClientDeviceType = "desktop" Mobile ClientDeviceType = "mobile" Tablet ClientDeviceType = "tablet" Bot ClientDeviceType = "bot" Unknown ClientDeviceType = "unknown" )