gen icon indicating copy to clipboard operation
gen copied to clipboard

Add a hook function after db operation inside http handlers

Open crimson-gao opened this issue 3 years ago • 0 comments

hey, there. I wonder if we counld add a post hook function inside http handlers. We can modify fields here. Here's an example.

func GetAllSystemRole_(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
        // ..... some  code

	result := &PagedResults{Page: page, PageSize: pagesize, Data: records, TotalRecords: totalRows}
        if err := systemrole_.AfterDBOperation(); err != nil {.  // add hook here
		returnError(ctx, w, r, dao.ErrServerInternal)
	}
	writeJSON(ctx, w, result)
}

crimson-gao avatar Apr 04 '22 10:04 crimson-gao