mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-12-24 01:00:18 +01:00
Initial decoding from incoming block changes.
This commit is contained in:
parent
02593a22d1
commit
3f13738d41
@ -4,7 +4,11 @@
|
|||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "net/http"
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
type tileUpdater struct {
|
type tileUpdater struct {
|
||||||
mapDir string
|
mapDir string
|
||||||
@ -12,6 +16,11 @@ type tileUpdater struct {
|
|||||||
redisPort int
|
redisPort int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type xz struct {
|
||||||
|
X int16
|
||||||
|
Z int16
|
||||||
|
}
|
||||||
|
|
||||||
func newTileUpdater(mapDir, redisHost string, redisPort int) *tileUpdater {
|
func newTileUpdater(mapDir, redisHost string, redisPort int) *tileUpdater {
|
||||||
return &tileUpdater{
|
return &tileUpdater{
|
||||||
mapDir: mapDir,
|
mapDir: mapDir,
|
||||||
@ -21,5 +30,14 @@ func newTileUpdater(mapDir, redisHost string, redisPort int) *tileUpdater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (tu *tileUpdater) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
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)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user