tile.go 515 B

1234567891011121314151617181920212223242526272829303132
  1. package tile
  2. import (
  3. "fmt"
  4. "net/http"
  5. "time"
  6. "appengine"
  7. "appengine/datastore"
  8. )
  9. type Tile struct {
  10. Created time.Time
  11. }
  12. func init() {
  13. http.HandleFunc("/", handleRoolPath)
  14. }
  15. func handleRoolPath(w http.ResponseWriter, r *http.Request) {
  16. ctx := appengine.NewContext(r)
  17. key := datastore.NewKey(ctx, "Tile", "root", 0, nil)
  18. tile := new(Tile)
  19. if err := datastore.Get(ctx, key, tile); err != nil {
  20. now := new time.Time()
  21. tile.Created = now
  22. }
  23. fmt.Fprint(w, "Root slash " +tile.Created.String())
  24. }