api

package
v0.0.0-...-2d47247 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleLiveness

func HandleLiveness(w http.ResponseWriter, r *http.Request)

func RegisterEndpoints

func RegisterEndpoints(mux *http.ServeMux, cfg *ApiConfig)

func RespondWithError

func RespondWithError(w http.ResponseWriter, code int, msg string)

Types

type ApiConfig

type ApiConfig struct {
	NuthatcherApiKey string
	DbURL            string
	DbQueries        *database.Queries
	Db               *sql.DB
	S3Client         *s3.Client
	BucketName       string
	// contains filtered or unexported fields
}

func (*ApiConfig) CacheImages

func (cfg *ApiConfig) CacheImages() error

func (*ApiConfig) GetNuthatchBirds

func (cfg *ApiConfig) GetNuthatchBirds(page, pageSize int) (BirdsJson, error)

func (*ApiConfig) HandleReadiness

func (cfg *ApiConfig) HandleReadiness(w http.ResponseWriter, r *http.Request)

func (*ApiConfig) PopulateBirdDB

func (cfg *ApiConfig) PopulateBirdDB() error

func (*ApiConfig) PopulateRatingsDB

func (cfg *ApiConfig) PopulateRatingsDB() error

func (*ApiConfig) PresignImageURL

func (cfg *ApiConfig) PresignImageURL(storedURL string) string

PresignImageURL returns a presigned URL for a Tigris object, cached for 23 hours. Caching ensures all users get the same URL for the same image, allowing browsers to cache the fetched image across page loads. Falls back to the stored URL unchanged for non-Tigris images.

func (*ApiConfig) ScoreMatch

func (cfg *ApiConfig) ScoreMatch(winner, loser database.Bird) error

type Bird

type Bird struct {
	Images      []string `json:"images"`
	LengthMin   string   `json:"lengthMin"`
	LengthMax   string   `json:"lengthMax"`
	Name        string   `json:"name"`
	ID          int      `json:"id"`
	SciName     string   `json:"sciName"`
	Region      []string `json:"region"`
	Family      string   `json:"family"`
	Order       string   `json:"order"`
	Status      string   `json:"status"`
	WingspanMin string   `json:"wingspanMin,omitempty"`
	WingspanMax string   `json:"wingspanMax,omitempty"`
}

type BirdsJson

type BirdsJson struct {
	Birds    []Bird `json:"entities"`
	Total    int    `json:"total"`
	Page     int    `json:"page"`
	PageSize int    `json:"pageSize"`
}

type HealthStatus

type HealthStatus struct {
	Status string `json:"status"`
}

Jump to

Keyboard shortcuts

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