1 Star 0 Fork 0

陈然威/pruner

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

Pruner

a util to make iris more beautiful

Brief

是一个用iris web框架来完成整体web服务的框架

启动

在_example,go run ./main.go

已加功能

1. mvc基础框架

其中hello服务是有view的web服务 movie服务是api服务 返回view还是api的关键在于controller中方法的返回值,如果是interface{}或具体的struct则为api

controllers -> services -> respositories -> storage

datamodels定义了关键structures

2. input validation

web/controllers/hello_controller.go - GetProfile 逻辑上的校验通常放在service层

3. 错误处理

common里面定义了错误代码和错误json返回函数 web/controller/movie_controller.go - Get()和GetBy() 给出了实例

4. logging

use logrus to log access, see common/logger.go

//TODO: logrus will involve several strage spaces //TODO: redis log

5. 数据库使用

mysql使用xorm.io/xorm storage/mysql/index.go repositories/movie_db.go

redis使用github.com/gomodule/redigo/redis storage/redis/index.go repositories/image_repository.go

6. config

使用了toml格式

用了iris-toml和github.com/BurntSushi/toml

7. route

main.go

8. post文件

必须用form(不可用formfile和json混合模式) movie_controller.go:PostAdd

9. testing

main_test.go https://github.com/gavv/httpexpect

在线jsonschema生成工具

https://www.liquid-technologies.com/online-json-to-schema-converter

10. 跨域

封装到了middleware/cors

  1. 返回头加上跨域设置

  2. 加入app.AllowMethods(iris.MethodOptions),允许options查询

核心参考

https://iris-go.com/start/

https://github.com/kataras/iris/tree/master/_examples

http://c.biancheng.net/view/5405.html

https://github.com/JabinGP/demo-chatroom

空文件

简介

修剪iris的神器 展开 收起
取消

发行版 (1)

全部
5年前

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/mywisp/pruner.git
git@gitee.com:mywisp/pruner.git
mywisp
pruner
pruner
master

搜索帮助