Beispiel #1
0
func NewServer(p string) (*zerver.Server, error) {
	if p == "" {
		p = "/"
	}

	s := zerver.NewServer()
	// s.AddHandleFunc("/stop", "GET", func(req zerver.Request, resp zerver.Response) {
	// 	req.Server().Destroy()
	// })
	// infos["/stop"] = "stop pprof server"
	return s, Enable("/", s.Router, s.RootFilters)
}
Beispiel #2
0
func TestXsrf(t *testing.T) {
	tt := testing2.Wrap(t)
	key := "123456789"
	data := []byte(key)
	xsrf := &Xsrf{
		Secret: key,
	}
	s := zerver.NewServer()
	go s.Start(nil)
	time.Sleep(1 * time.Millisecond)

	xsrf.Init(s)
	signing := xsrf.sign(data)
	d := xsrf.verify(signing)
	tt.True(bytes.Equal(data, d))
}