Esempio n. 1
0
File: logger.go Progetto: widaT/web
func main() {
	f, err := os.Create("server.log")
	if err != nil {
		println(err.Error())
		return
	}
	logger := log.New(f, "", log.Ldate|log.Ltime)
	web.Get("/(.*)", hello)
	web.SetLogger(logger)
	web.Run("0.0.0.0:9999")
}
Esempio n. 2
0
func main() {
	rand.Seed(time.Now().UnixNano())
	web.Config.CookieSecret = "7C19QRmwf3mHZ9CPAaPQ0hsWeufKd"
	web.Get("/", func(ctx *web.Context) string {
		ctx.Redirect(302, "/said")
		return ""
	})
	web.Get("/said", func() string { return form })
	web.Post("/say", func(ctx *web.Context) string {
		uid := fmt.Sprintf("%d\n", rand.Int63())
		ctx.SetSecureCookie("user", uid, 3600)
		users[uid] = ctx.Params["said"]
		return `<a href="/final">Click Here</a>`
	})
	web.Get("/final", func(ctx *web.Context) string {
		uid, _ := ctx.GetSecureCookie("user")
		return "You said " + users[uid]
	})
	web.Run("0.0.0.0:9999")
}
Esempio n. 3
0
File: cookie.go Progetto: widaT/web
func main() {
	web.Get("/", index)
	web.Post("/update", update)
	web.Run("0.0.0.0:9999")
}
Esempio n. 4
0
File: params.go Progetto: widaT/web
func main() {
	web.Get("/", index)
	web.Post("/process", process)
	web.Run("0.0.0.0:9999")
}
Esempio n. 5
0
func main() {
	web.Get("/([0-9]+)", hello)
	web.Run("0.0.0.0:9999")
}
Esempio n. 6
0
func main() {
	web.Get("/", index)
	web.Post("/multipart", multipart)
	web.Run("0.0.0.0:9999")
}