package wizardbacon import ( "encoding/json" "fmt" "net/http" ) const endpoint = "https://wizard-bacon.4zb.org/index.json" // Response is the response from the Wizard Bacon server. type Response struct { // ProjectName is the name of your new project. You're welcome ProjectName string `json:"projectName"` // Intro is some randomized text used to present ProjectName in the UI. Intro string `json:"intro"` // Outro is some randomized text used to present ProjectName in the UI. Outro string `json:"outro"` } // Fetch queries the server at https://wizard-bacon.4zb.org and returns a response object // with the Project name and some other, randomized UI test. func Fetch() (Response, error) { var resp Response if r, err := http.Get(endpoint); err != nil { return resp, fmt.Errorf(`could not fetch Wizard Bacon response: %w`, err) } else if err = json.NewDecoder(r.Body).Decode(&resp); err != nil { return resp, fmt.Errorf(`could not understand Wizard Bacon response: %w`, err) } else { r.Body.Close() } return resp, nil }