• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang forest.New函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/ursiform/forest.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了New函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: TestAuthenticateFailure

func TestAuthenticateFailure(t *testing.T) {
	method := "GET"
	path := root + "/authenticate/failure"
	app := forest.New("")
	app.RegisterRoute(root, newRouter(app))
	params := &requested{method: method, path: path}
	want := &wanted{code: http.StatusUnauthorized, success: false}
	makeRequest(t, app, params, want)
}
开发者ID:ursiform,项目名称:forest-wares,代码行数:9,代码来源:wares-test_test.go


示例2: TestSessionGetSuccessCreateEmpty

func TestSessionGetSuccessCreateEmpty(t *testing.T) {
	method := "GET"
	path := root + "/session-get"
	app := forest.New("")
	app.RegisterRoute(root, newRouter(app))
	params := &requested{method: method, path: path}
	want := &wanted{code: http.StatusOK, success: true}
	makeRequest(t, app, params, want)
}
开发者ID:ursiform,项目名称:forest-wares,代码行数:9,代码来源:wares-test_test.go


示例3: TestMethodNotAllowed

func TestMethodNotAllowed(t *testing.T) {
	method := "OPTIONS"
	path := root
	app := forest.New("")
	app.RegisterRoute(root, newRouter(app))
	params := &requested{method: method, path: path}
	want := &wanted{code: http.StatusMethodNotAllowed, success: false}
	makeRequest(t, app, params, want)
}
开发者ID:ursiform,项目名称:forest-wares,代码行数:9,代码来源:wares-test_test.go


示例4: TestServerError

func TestServerError(t *testing.T) {
	method := "GET"
	path := root + "/server-error"
	app := forest.New("")
	app.RegisterRoute(root, newRouter(app))
	params := &requested{method: method, path: path}
	want := &wanted{code: http.StatusInternalServerError, success: false}
	makeRequest(t, app, params, want)
}
开发者ID:ursiform,项目名称:forest-wares,代码行数:9,代码来源:wares-test_test.go


示例5: TestNotFound

func TestNotFound(t *testing.T) {
	method := "GET"
	path := root + "/not-found"
	app := forest.New("")
	app.RegisterRoute(root, newRouter(app))
	params := &requested{method: method, path: path}
	want := &wanted{code: http.StatusNotFound, success: false}
	makeRequest(t, app, params, want)
}
开发者ID:ursiform,项目名称:forest-wares,代码行数:9,代码来源:wares-test_test.go


示例6: TestCSRFFailureBodyNil

func TestCSRFFailureBodyNil(t *testing.T) {
	method := "GET"
	path := root + "/csrf"
	app := forest.New("")
	app.RegisterRoute(root, newRouter(app))
	params := &requested{method: method, path: path}
	want := &wanted{code: http.StatusBadRequest, success: false}
	makeRequest(t, app, params, want)
}
开发者ID:ursiform,项目名称:forest-wares,代码行数:9,代码来源:wares-test_test.go


示例7: TestAuthenticateSuccess

func TestAuthenticateSuccess(t *testing.T) {
	method := "GET"
	path := root + "/authenticate/success"
	app := forest.New("")
	app.RegisterRoute(root, newRouter(app))
	params := &requested{method: method, path: path}
	want := &wanted{code: http.StatusOK, success: true}
	makeRequest(t, app, params, want)
}
开发者ID:ursiform,项目名称:forest-wares,代码行数:9,代码来源:wares-test_test.go


示例8: TestSessionSetUpdateError

func TestSessionSetUpdateError(t *testing.T) {
	method := "GET"
	path := root + "/session-set"
	auth := sessionIDWithUpdateError
	app := forest.New("")
	app.RegisterRoute(root, newRouter(app))
	params := &requested{auth: auth, method: method, path: path}
	want := &wanted{code: http.StatusInternalServerError, success: false}
	makeRequest(t, app, params, want)
}
开发者ID:ursiform,项目名称:forest-wares,代码行数:10,代码来源:wares-test_test.go


示例9: TestSessionSetSuccess

func TestSessionSetSuccess(t *testing.T) {
	method := "GET"
	path := root + "/session-set"
	auth := sessionIDExistent
	app := forest.New("")
	app.RegisterRoute(root, newRouter(app))
	params := &requested{auth: auth, method: method, path: path}
	want := &wanted{code: http.StatusOK, success: true}
	makeRequest(t, app, params, want)
}
开发者ID:ursiform,项目名称:forest-wares,代码行数:10,代码来源:wares-test_test.go


示例10: TestSessionGetSuccessCreateErrorWithDeleteError

func TestSessionGetSuccessCreateErrorWithDeleteError(t *testing.T) {
	method := "GET"
	path := root + "/session-get/create-error"
	auth := sessionIDWithDeleteError
	app := forest.New("")
	app.RegisterRoute(root, newRouter(app))
	params := &requested{auth: auth, method: method, path: path}
	want := &wanted{code: http.StatusOK, success: true}
	makeRequest(t, app, params, want)
}
开发者ID:ursiform,项目名称:forest-wares,代码行数:10,代码来源:wares-test_test.go


示例11: TestCSRFSuccess

func TestCSRFSuccess(t *testing.T) {
	method := "GET"
	path := root + "/csrf"
	body := []byte(fmt.Sprintf("{\"sessionid\": \"%s\"}", sessionIDExistent))
	app := forest.New("")
	app.RegisterRoute(root, newRouter(app))
	params := &requested{body: body, method: method, path: path}
	want := &wanted{code: http.StatusOK, success: true}
	makeRequest(t, app, params, want)
}
开发者ID:ursiform,项目名称:forest-wares,代码行数:10,代码来源:wares-test_test.go


示例12: TestCSRFFailureWrongSessionID

func TestCSRFFailureWrongSessionID(t *testing.T) {
	method := "GET"
	path := root + "/csrf"
	body := []byte(fmt.Sprintf("{\"sessionid\": \"WRONG-SESSION-ID\"}"))
	app := forest.New("")
	app.RegisterRoute(root, newRouter(app))
	params := &requested{body: body, method: method, path: path}
	want := &wanted{code: http.StatusBadRequest, success: false}
	makeRequest(t, app, params, want)
}
开发者ID:ursiform,项目名称:forest-wares,代码行数:10,代码来源:wares-test_test.go


示例13: TestBodyParserSuccess

func TestBodyParserSuccess(t *testing.T) {
	method := "POST"
	path := root + "/body-parser/success"
	body := []byte(arbitraryJSON)
	app := forest.New("")
	app.RegisterRoute(root, newRouter(app))
	params := &requested{body: body, method: method, path: path}
	want := &wanted{code: http.StatusOK, success: true}
	makeRequest(t, app, params, want)
}
开发者ID:ursiform,项目名称:forest-wares,代码行数:10,代码来源:wares-test_test.go


示例14: TestBodyParserFailureNoInit

func TestBodyParserFailureNoInit(t *testing.T) {
	method := "POST"
	path := root + "/body-parser/failure/no-init"
	body := []byte(arbitraryJSON)
	app := forest.New("")
	app.RegisterRoute(root, newRouter(app))
	params := &requested{body: body, method: method, path: path}
	want := &wanted{code: http.StatusInternalServerError, success: false}
	makeRequest(t, app, params, want)
}
开发者ID:ursiform,项目名称:forest-wares,代码行数:10,代码来源:wares-test_test.go


示例15: TestBodyParserFailureBadInput

func TestBodyParserFailureBadInput(t *testing.T) {
	method := "POST"
	path := root + "/body-parser/success"
	body := []byte("{BAD JSON}")
	app := forest.New("")
	app.RegisterRoute(root, newRouter(app))
	params := &requested{body: body, method: method, path: path}
	want := &wanted{code: http.StatusBadRequest, success: false}
	makeRequest(t, app, params, want)
}
开发者ID:ursiform,项目名称:forest-wares,代码行数:10,代码来源:wares-test_test.go


示例16: TestSafeErrorFilter

func TestSafeErrorFilter(t *testing.T) {
	method := "GET"
	app := forest.New("")
	app.SafeErrorFilter = func(err error) error {
		if err.Error() == customSafeErrorMessage {
			return err
		} else {
			return nil
		}
	}
	app.RegisterRoute(root, newRouter(app))
	// test safe errors via custom filter
	path := root + "/safe-error/success"
	params := &requested{method: method, path: path}
	want := &wanted{code: http.StatusInternalServerError, success: false}
	_, forestResponse := makeRequest(t, app, params, want)
	if forestResponse.Message != customSafeErrorMessage {
		t.Errorf("%s %s should return message: %s",
			method, path, customSafeErrorMessage)
	}
	// test unsafe errors not passing through custom filter
	path = root + "/safe-error/failure"
	params = &requested{method: method, path: path}
	want = &wanted{code: http.StatusInternalServerError, success: false}
	_, forestResponse = makeRequest(t, app, params, want)
	if forestResponse.Message == customUnsafeErrorMessage {
		t.Errorf("%s %s should NOT return unsafe message: %s",
			method, path, customUnsafeErrorMessage)
	}
	// test unsafe errors passing through if app.Config.Debug is true
	app.Config.Debug = true
	path = root + "/safe-error/failure"
	params = &requested{method: method, path: path}
	want = &wanted{code: http.StatusInternalServerError, success: false}
	_, forestResponse = makeRequest(t, app, params, want)
	if forestResponse.Message != customUnsafeErrorMessage {
		t.Errorf("%s %s should return unsafe message if %s is true: %s",
			method, path, "app.Config.Debug", customUnsafeErrorMessage)
	}
}
开发者ID:ursiform,项目名称:forest-wares,代码行数:40,代码来源:wares-test_test.go



注:本文中的github.com/ursiform/forest.New函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang forest.App类代码示例发布时间:2022-05-28
下一篇:
Golang bear.Context类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap