示例#1
0
文件: errors.go 项目: xyproto/web
func main() {
	web.Get("/", root)
	web.Get("/404", notfound)
	web.Get("/teapot", teapot)
	web.Get("/generic", generic)
	web.Run(":3000")
}
示例#2
0
func main() {
	rand.Seed(time.Now().UnixNano())
	web.Config.CookieSecret = "7C19QRmwf3mHZ9CPAaPQ0hsWeufKd"
	web.Get("/said", func() string { return form })
	web.Post("/say", func(ctx *web.Context) string {
		uid := strconv.FormatInt(rand.Int63(), 10)
		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")
}
示例#3
0
文件: logger.go 项目: xyproto/web
func main() {
	f, err := os.Create("server.log")
	if err != nil {
		println(err)
		return
	}
	logger := log.New(f, "", log.Ldate|log.Ltime)
	web.Get("/(.*)", hello)
	web.SetLogger(logger)
	web.Run(":3000")
}
示例#4
0
文件: tlshello.go 项目: skammer/web
func main() {
	config := tls.Config{
		Time: nil,
	}

	config.Certificates = make([]tls.Certificate, 1)
	var err error
	config.Certificates[0], err = tls.X509KeyPair(SERVER_CERT, SERVER_KEY)
	if err != nil {
		fmt.Println(err)
	}

	web.Get("/(.*)", hello)
	web.RunSecure("0.0.0.0:9998", config)
}
示例#5
0
文件: params.go 项目: xyproto/web
func main() {
	web.Get("/", root)
	web.Post("/process", process)
	web.Run(":3000")
}
示例#6
0
文件: modules.go 项目: skammer/web
func main() {
	// Add AuthHandler to our PreModule list
	web.AddPreModule(AuthHandler)
	web.Get("/(.*)", Hello)
	web.Run("0.0.0.0:9999")
}
示例#7
0
func main() {
	web.Get("/", root)
	web.Get("/a", a)
	web.Get("/b", b)
	web.Get("/c", c)
	web.Get("/d", d)
	web.Get("/e", e)
	web.Get("/f", myhandlertype("return io.Reader"))
	web.Get("/g", g)
	web.Get("/h", h)
	web.Get("/i", i)
	web.Get("/j", j)
	web.Run(":3000")
}
示例#8
0
func main() {
	web.Config.CookieSecret = "7C19QRmwf3mHZ9CPAaPQ0hsWeufKd"
	web.Get("/", root)
	web.Post("/say", say)
	web.Run(":3000")
}
示例#9
0
文件: helloTLS.go 项目: xyproto/web
func main() {
	web.Get("/(.*)", hello)
	// You can create an example cert using generate_cert.go include in pkg crypto/tls
	web.RunTLS(":3000", "/tmp/cert.pem", "/tmp/key.pem")
}
示例#10
0
文件: hello.go 项目: xyproto/web
func main() {
	web.Get("/(.*)", hello)
	web.Run(":3000")
}
示例#11
0
文件: wrapper.go 项目: xyproto/web
func main() {
	// Wrap everything in the AuthHandler
	web.AddWrapper(AuthHandler)
	web.Get("/(.*)", Hello)
	web.Run(":3000")
}
示例#12
0
文件: compress.go 项目: xyproto/web
func main() {
	web.AddWrapper(web.CompressWrapper)
	web.Get("/", root)
	web.Run(":3000")
}
示例#13
0
文件: hello.go 项目: skammer/web
func main() {
	web.Get("/plain/(.*)", plain)
	web.Get("/(.*)", hello)
	web.Run("0.0.0.0:9999")
}