util

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertTimeAgoString

func ConvertTimeAgoString(t time.Time) string

func FormatHTTPError added in v0.19.0

func FormatHTTPError(action string, resp *http.Response) error

FormatHTTPError reads a non-2xx HTTP response and returns an error that preserves whatever the server actually said.

The Zeabur API returns JSON bodies of the form

{"code": "REQUIRE_PAID_PLAN", "error": "Upload size ... exceeds ..."}

for client-visible failures. When that shape is present, the message and (if available) code are surfaced. Otherwise the raw body is included so the user still has something to act on instead of a bare status code.

action is a short verb phrase describing what failed, e.g. "create upload session".

func UploadTimeout added in v0.19.0

func UploadTimeout(contentLength int64) time.Duration

UploadTimeout returns how long an upload of contentLength bytes is allowed to take: a 2-minute floor plus one second per 256 KiB of payload.

http.Client.Timeout covers the entire request including body transfer, so a fixed timeout makes large uploads fail on slow links no matter how patient the user is. The 256 KiB/s floor is deliberately conservative (~2 Mbps); a 50 MiB zip gets ~5.3 minutes.

func ValidateTemplate

func ValidateTemplate(templateSpec []byte) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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