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
#!/bin/bash | |
# bashsupport disable=BP5006 | |
set -euo pipefail | |
############################################################################## | |
# Global Script Variables | |
############################################################################## | |
SCRIPT="$(command -v "$0")" | |
if [[ ! "$SCRIPT" =~ ^/ ]]; then SCRIPT="$PWD/$SCRIPT"; fi |
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
`public/config.js` | |
const config = (() => { | |
return { | |
"TEST_ONE": "hello", | |
"TEST_TWO": "world" | |
}; | |
})(); | |
`src/index.template.html` |
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
import ( | |
"github.com/joomcode/errorx" | |
"sync" | |
) | |
// Merge fans multiple error channels in to a single error channel | |
func Merge(errChans ...<-chan error) <-chan error { | |
mergedChan := make(chan error) | |
var errors []error |
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
func main() { | |
conn := weatherAPI{ | |
Scheme: "https", | |
Host: "api.weatherapi.com", | |
Endpoints: weatherEndpoints{ | |
Forecast: endpoint{ | |
Path: "/forecast.json", | |
Method: "GET", | |
}, | |
Sports: endpoint{ |
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
type Formatter func() (string, *url.URL) | |
func (w *weatherAPI) ForecastURL(date, region string) Formatter { | |
return func() (string, *url.URL) { | |
u := &url.URL{ | |
Scheme: w.Scheme, | |
Host: w.Host, | |
Path: w.Endpoints.Forecast.Path, | |
} |
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
package main | |
import ( | |
"log" | |
) | |
type endpoint struct { | |
Path string `yaml:"path"` | |
Method string `yaml:"method"` | |
} |
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
weatherapi: | |
scheme: https | |
host: http://api.weatherapi.com/v1 | |
endpoints: | |
forecast: | |
path: /forecast.json | |
method: GET | |
sports: | |
path: /sports.json | |
method: GET |
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
// main.go | |
package main | |
import ( | |
"app/connections" | |
"log" | |
) | |
func main() { | |
log.Println(connections.Connections.WeatherAPI) |
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
func GracefullyListenAndServe(ctx context.Context, servePort string, rtr *mux.Router) { | |
http.Handle("/", rtr) | |
h := &http.Server{ | |
Addr: fmt.Sprintf(":%v", servePort), | |
Handler: handlers.CORS()(rtr), | |
} | |
sig := make(chan os.Signal, 1) |
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
var ReadCollectionPayload = func(w http.ResponseWriter, r *http.Request) { | |
(w).Header().Set("Content-Type", "application/json") | |
var payload mongo.QueryInputs | |
// Try to decode the request body into the struct. If there is an error, | |
// respond to the client with the error message and a 400 status code. | |
err := json.NewDecoder(r.Body).Decode(&payload) | |
if err != nil { | |
writeStatus(&w, http.StatusBadRequest, "invalid query payload") |
NewerOlder