# pruner **Repository Path**: mywisp/pruner ## Basic Information - **Project Name**: pruner - **Description**: 修剪iris的神器 - **Primary Language**: Go - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-07-10 - **Last Updated**: 2023-02-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## 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