Ejemplo n.º 1
0
func TestRecf(t *testing.T) {
	sb := NewSrvSessionBuilder("", "/", "rtest", 2000, 500)
	mux := NewSessionMux("", sb)
	mux.HFunc("^/t1.*$", RecF)
	mux.HFunc("^/t2.*$", RecF2)
	ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		mux.ServeHTTP(w, r)
	}))
	defer ts.Close()
	util.FWrite("/tmp/test.txt", "testing")
	fmt.Println(util.HPostF(fmt.Sprintf("%v/t1", ts.URL), nil, "file", "/tmp/test.txt"))
	fmt.Println(util.HPostF(fmt.Sprintf("%v/t1", ts.URL), nil, "file2", "/tmp/test.txt"))
	fmt.Println(util.HPostF(fmt.Sprintf("%v/t2", ts.URL), nil, "file", "/tmp/test.txt"))
	fmt.Println(util.HPostF(fmt.Sprintf("%v/t1", ts.URL), nil, "file", "/tmp/test.txt2"))
}
Ejemplo n.º 2
0
func (s *Server) PostF(url, fkey, fp string, fields map[string]string) (string, error) {
	return util.HPostF(fmt.Sprintf("%v%v", s.URL, url), fields, fkey, fp)
}