-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package fj | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"io" | ||
"net/http" | ||
) | ||
|
||
func CloudRun(cnf *Config, seed int) (map[string]float64, error) { | ||
return googleCloudRun(cnf, seed) | ||
} | ||
|
||
func googleCloudRun(cnf *Config, seed int) (map[string]float64, error) { | ||
url := fmt.Sprintf("%s?seed=%d", cnf.CloudURL, seed) | ||
|
||
resp, err := http.Get(url) | ||
if err != nil { | ||
return nil, fmt.Errorf("error making GET request to %s: %v", url, err) | ||
} | ||
defer resp.Body.Close() | ||
|
||
body, err := io.ReadAll(resp.Body) | ||
if err != nil { | ||
return nil, fmt.Errorf("error reading response body: %v", err) | ||
} | ||
|
||
var data map[string]float64 | ||
if err := json.Unmarshal(body, &data); err != nil { | ||
return nil, fmt.Errorf("error parsing response body: %v", err) | ||
} | ||
|
||
return data, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters