Documentation ¶
Index ¶
- func CrudDBAll(r chi.Router, sess sqlbuilder.Database)
- func CrudDBExcept(r chi.Router, sess sqlbuilder.Database, except []string)
- func CrudDBOnly(r chi.Router, sess sqlbuilder.Database, only []string)
- func CrudTable(r chi.Router, sess sqlbuilder.Database, table string, prefix string)
- func FileServer(r chi.Router, path string, root http.FileSystem)
- func ServeStatic(r chi.Router, path string, dir string)
- type CrudController
- func (c *CrudController) All(w http.ResponseWriter, r *http.Request)
- func (c *CrudController) Create(w http.ResponseWriter, r *http.Request)
- func (c *CrudController) Delete(w http.ResponseWriter, r *http.Request)
- func (c *CrudController) JSON(w http.ResponseWriter, data interface{})
- func (c *CrudController) One(w http.ResponseWriter, r *http.Request)
- func (c *CrudController) Pagination(w http.ResponseWriter, r *http.Request)
- func (c *CrudController) Table() db.Collection
- func (c *CrudController) Update(w http.ResponseWriter, r *http.Request)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CrudDBAll ¶
func CrudDBAll(r chi.Router, sess sqlbuilder.Database)
CrudDBAll 自动生成针对于所有表的增删查改 `GET /table` 分页结果 `GET /table/{id}“ 根据id获取结果 `POST /table` 新增记录 `PUT /table` 更新记录 `DELETE /table/{id}` 删除记录 `GET /table/all` 所有结果
func CrudDBExcept ¶
func CrudDBExcept(r chi.Router, sess sqlbuilder.Database, except []string)
CrudDBExcept 自动生成针对于排除指定表外所有表的增删查改
func CrudDBOnly ¶
func CrudDBOnly(r chi.Router, sess sqlbuilder.Database, only []string)
CrudDBOnly 自动生成针对于指定表的增删查改
func FileServer ¶
func FileServer(r chi.Router, path string, root http.FileSystem)
FileServer conveniently sets up a http.FileServer handler to serve static files from a http.FileSystem.
Types ¶
type CrudController ¶
type CrudController struct { GetParam func(*http.Request, string) string Sess sqlbuilder.Database TableName string }
CrudController Crud操作集合
func (*CrudController) All ¶
func (c *CrudController) All(w http.ResponseWriter, r *http.Request)
All 一次性获取所有数据 orderby=-id
func (*CrudController) Create ¶
func (c *CrudController) Create(w http.ResponseWriter, r *http.Request)
Create 新增实例
func (*CrudController) Delete ¶
func (c *CrudController) Delete(w http.ResponseWriter, r *http.Request)
Delete 通过id删除实例
func (*CrudController) JSON ¶
func (c *CrudController) JSON(w http.ResponseWriter, data interface{})
JSON 返回json结果
func (*CrudController) One ¶
func (c *CrudController) One(w http.ResponseWriter, r *http.Request)
One 根据id获取单个实例
func (*CrudController) Pagination ¶
func (c *CrudController) Pagination(w http.ResponseWriter, r *http.Request)
Pagination 分页显示 , 默认offset=0, limit=10, where={"key": "value"}, orderby=-id
func (*CrudController) Update ¶
func (c *CrudController) Update(w http.ResponseWriter, r *http.Request)
Update 更新实例
Click to show internal directories.
Click to hide internal directories.