)
type Env struct {
- Db *db.DB
- C *spotify.Client
+ Db *db.DB
+ C *spotify.Client
+ CorsOrigin string
}
func New() (*Env, error) {
if err != nil {
return nil, err
}
- return &Env{Db: db, C: client}, nil
+ return &Env{
+ Db: db,
+ C: client,
+ CorsOrigin: "http://brackets.jacobcasper.com",
+ },
+ nil
+}
+
+func (e *Env) Local() {
+ e.CorsOrigin = "*"
}
return
}
+ w.Header().Set("Access-Control-Allow-Origin", env.CorsOrigin)
+ w.Header().Set("Vary", "Origin")
w.Header().Set("Content-Type", "application/json")
artistId := r.FormValue("id")
return
}
+ w.Header().Set("Access-Control-Allow-Origin", env.CorsOrigin)
+ w.Header().Set("Vary", "Origin")
w.Header().Set("Content-Type", "application/json")
+
genreName := r.FormValue("genre_name")
if genreName != "" {
rows, err := env.Db.Db.Query(`
return
}
+ w.Header().Set("Access-Control-Allow-Origin", env.CorsOrigin)
+ w.Header().Set("Vary", "Origin")
w.Header().Set("Content-Type", "application/json")
genreName := r.FormValue("name")