Esempio n. 1
0
func apiDetail(ctx context.Context, w http.ResponseWriter, r *http.Request) error {
	id := wok.Var(ctx, "id")
	res := struct {
		ID string
	}{id}
	return render.Yield(ctx, 201, res)
}
Esempio n. 2
0
func genericRenderTest(mw noodle.Middleware, data interface{}, mutators ...headerMutator) (w *httptest.ResponseRecorder, err error) {
	h := noodle.New(mw).Then(
		func(c context.Context, w http.ResponseWriter, r *http.Request) error {
			return render.Yield(c, 200, data)
		})

	r, _ := http.NewRequest("GET", "http://localhost/testId", nil)
	for _, m := range mutators {
		m(r)
	}
	w = httptest.NewRecorder()
	err = h(context.TODO(), w, r)
	return
}
Esempio n. 3
0
func dashIndex(ctx context.Context, w http.ResponseWriter, r *http.Request) error {
	res := map[string]interface{}{
		"User": mw.GetUser(ctx),
	}
	return render.Yield(ctx, 201, res)
}
Esempio n. 4
0
func apiIndex(ctx context.Context, w http.ResponseWriter, r *http.Request) error {
	res := []int{1, 2, 3, 4, 5}
	return render.Yield(ctx, 200, res)
}