From 294fabaf1ce89560b6de6619637985e73c217a11 Mon Sep 17 00:00:00 2001 From: Ted Spare Date: Thu, 27 Apr 2023 20:58:33 -0400 Subject: [PATCH] Add api/today.go --- api/today.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/api/today.go b/api/today.go index 63e77ae..e3d8a1f 100644 --- a/api/today.go +++ b/api/today.go @@ -10,21 +10,22 @@ import ( ) func Handler(w http.ResponseWriter, r *http.Request) { - supabaseUrl := os.Getenv("SUPABASE_URL") - supabaseKey := os.Getenv("SUPABASE_KEY") - supabaseClient := supabase.CreateClient(supabaseUrl, supabaseKey) + supabaseUrl := os.Getenv("SUPABASE_URL") + supabaseKey := os.Getenv("SUPABASE_KEY") + supabaseClient := supabase.CreateClient(supabaseUrl, supabaseKey) - // Pull today's row from Supabase DB - var results map[string]interface{} - err := supabaseClient.DB.From("classes").Select("*").Single().Execute(&results) + // Pull today's row from Supabase DB + var results map[string]interface{} + err := supabaseClient.DB.From("classes").Select("*").Single().Execute(&results) if err != nil { - panic(err) - } + panic(err) + } // Convert results to JSON jsonResults, _ := json.Marshal(results) w.Header().Add("Content-Type", "application/json") - fmt.Fprintf(w, string(jsonResults)) + w.Header().Add("User-Agent", "auto-repo") + fmt.Fprintf(w, string(jsonResults)) } \ No newline at end of file