aboutsummaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@gmail.com>2016-11-21 19:37:50 -0500
committerGuillaume Horel <guillaume.horel@gmail.com>2016-11-21 19:37:50 -0500
commit236f65ac487731da53966da88a8b6fe2c4d7a625 (patch)
treed589b90d0f3c894b81175339461ebcea5b7d4cb0 /main.go
parent0e5bb6b93920fe9782ab976bb556f66707f0db7f (diff)
downloadlastfm-api-236f65ac487731da53966da88a8b6fe2c4d7a625.tar.gz
Use Println where it makes sense
Diffstat (limited to 'main.go')
-rw-r--r--main.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/main.go b/main.go
index 12d876c..381de33 100644
--- a/main.go
+++ b/main.go
@@ -17,20 +17,20 @@ func mainHandler(ds DataStore, w http.ResponseWriter, r *http.Request) {
protocol := r.FormValue("p")
if protocol != "1.2.1" && protocol != "1.2" {
- fmt.Fprintf(w, "FAILED Protocol mismatch\n")
+ fmt.Fprintln(w, "FAILED Protocol mismatch")
return
}
timestamp := r.FormValue("t")
ts, err := strconv.ParseInt(timestamp, 10, 0)
if err != nil {
- fmt.Fprintf(w, "FAILED Invalid timestamp\n")
+ fmt.Fprintln(w, "FAILED Invalid timestamp")
return
}
delta := time.Now().Unix() - ts
if delta > 30 || delta < -30 {
- fmt.Fprintf(w, "BADTIME\n")
+ fmt.Fprintln(w, "BADTIME")
return
}
@@ -38,17 +38,17 @@ func mainHandler(ds DataStore, w http.ResponseWriter, r *http.Request) {
auth := r.FormValue("a")
password, err := ds.GetPassword(user)
if (md5hex(password+timestamp) != auth) || err != nil {
- fmt.Fprintf(w, "BADAUTH\n")
+ fmt.Fprintln(w, "BADAUTH")
return
}
client := r.FormValue("c")
s := NewSession(user, client, protocol)
ds.PutSession(s)
- fmt.Fprint(w, "OK\n")
+ fmt.Fprintln(w, "OK")
fmt.Fprintf(w, "%s\n", s.Key)
- fmt.Fprint(w, "http://post.audioscrobbler.com:80/np\n")
- fmt.Fprint(w, "http://post.audioscrobbler.com:80/scrobble\n")
+ fmt.Fprintln(w, "http://post.audioscrobbler.com:80/np")
+ fmt.Fprintln(w, "http://post.audioscrobbler.com:80/scrobble")
} else {
fmt.Fprintf(w, "<html>This is an endpoint, see <a href=\"http://www.last.fm/api/submissions\">here</a></html>")
}
@@ -125,9 +125,9 @@ func scrobbleHandler(ds DataStore, w http.ResponseWriter, r *http.Request) {
if session, err := ds.GetSession(r.FormValue("s")); err != nil {
scrobbles := parseScrobbles(r.Form, session)
ds.PutScrobbles(scrobbles)
- fmt.Fprintf(w, "OK\n")
+ fmt.Fprintln(w, "OK")
} else {
- fmt.Fprintf(w, "BADSESSION\n")
+ fmt.Fprintln(w, "BADSESSION")
}
}
@@ -135,7 +135,7 @@ func nowPlayingHandler(ds DataStore, w http.ResponseWriter, r *http.Request) {
if _, err := ds.GetSession(r.FormValue("s")); err != nil {
fmt.Fprintln(w, "OK")
} else {
- fmt.Fprintf(w, "BADSESSION\n")
+ fmt.Fprintln(w, "BADSESSION")
}
}