Initial decoding from incoming block changes.

This commit is contained in:
Sascha L. Teichmann 2014-09-18 15:21:40 +02:00
parent 02593a22d1
commit 3f13738d41

View File

@ -4,7 +4,11 @@
package main
import "net/http"
import (
"encoding/json"
"log"
"net/http"
)
type tileUpdater struct {
mapDir string
@ -12,6 +16,11 @@ type tileUpdater struct {
redisPort int
}
type xz struct {
X int16
Z int16
}
func newTileUpdater(mapDir, redisHost string, redisPort int) *tileUpdater {
return &tileUpdater{
mapDir: mapDir,
@ -21,5 +30,14 @@ func newTileUpdater(mapDir, redisHost string, redisPort int) *tileUpdater {
}
func (tu *tileUpdater) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
// TODO: Implement me!
var err error
var data []xz
decoder := json.NewDecoder(r.Body)
if err = decoder.Decode(&data); err != nil {
log.Printf("WARN: JSON document broken: %s", err)
http.Error(rw, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
return
}
log.Printf("Changes: #%d %+v\n", len(data), data)
rw.WriteHeader(http.StatusOK)
}