1// Copyright 2011 Google Inc. All rights reserved.
2// Use of this source code is governed by the Apache 2.0
3// license that can be found in the LICENSE file.
4
5package later
6
7import (
8	"fmt"
9	"net/http"
10
11	"appengine"
12	"appengine/delay"
13)
14
15func init() {
16	http.HandleFunc("/", handle)
17}
18
19func handle(w http.ResponseWriter, r *http.Request) {
20	if r.URL.Path != "/" {
21		// ignore /favicon.ico, etc.
22		return
23	}
24
25	w.Header().Set("Content-Type", "text/plain; charset=utf-8")
26	fmt.Fprint(w, "I will run a function later.\n")
27
28	c := appengine.NewContext(r)
29	later.Call(c, "Please send my regards to your mother.")
30}
31
32// A function that can be executed later.
33var later = delay.Func("later", func(c appengine.Context, msg string) {
34	c.Infof("later, %q", msg)
35})
36