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) }
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 }
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) }
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) }