{"repo":"axiaoxin-com/pink-lady","free":true,"listed":false,"github":"https://github.com/axiaoxin-com/pink-lady","clone":"git clone https://github.com/axiaoxin-com/pink-lady.git","description":"a template project of gin app.","language":"Go","stars":79,"topics":["gin","go","gorm","zap","template-project","gin-framework","gin-boilerplate","boilerplate-application","viper","sentry"],"license":"Apache-2.0","category":"data-pipelines","readme_excerpt":"pink-lady Pinklady is a template project of gin app, which encapsulates mysql, redis, logging, viper, swagger, middlewares and other common components. pink-lady 是基于 Golang web 开发框架 gin 来进行 API服务/WEB网站 开发的示例项目，新建项目时可以使用它作为项目模板。 之所以叫 pink-lady 首先字面意思就是红粉佳人或粉红女郎，有这个性感的名字相信你更会好好对你的代码负责。 其次，因为 gin 就是国外六大类烈酒之一的金酒，是近百年来调制鸡尾酒时最常使用的基酒，其配方多达千种以上， 而 pink lady 是以 gin 作 base 的国标鸡尾酒之一，在这里 pink-lady 则是以 gin 作 base 的代码骨架模板之一 使用 pink-lady 模板创建项目 点击 创建你的 github 项目（使用该方式创建项目时，如需修改项目名称需手动修改） 或者手动本地创建（如想自定义项目名，推荐使用该方式）： 特性 - 使用 viper 加载配置，支持配置热更新，服务所有特性都通过配置文件控制 - 支持生成 swagger api 文档 - 封装数据库连接实例池，通过读取配置文件可以直接在代码中使用 gorm 和 sqlx 快速连接 mysql、sqlite3、postgresql、sqlserver - 封装 redis， redis sentinel， redis cluster 连接实例池 - 封装统一的 JSON 返回结构 - 集成 sentry 搜集错误 - 内置 GinLogger 中间件打印详细的访问日志，支持不同的 http 状态码使用不同的日志级别，通过配置开关打印请求头，请求餐宿，响应体等调试信息 - 内置 GinRecovery 中间件，异常服务默认按状态码返回 JSON 错误信息，panic 错误统一交由 GinLogger 打印，支持自定义输出格式 - 使用 logging 打印日志，支持 trace id，error 以上级别自动上报到 sentry - 支持 prometheus metrics exporter - 支持 ratelimiter 请求限频 - 通过配置集成 go html template，可自由注册 template funcs map - embed 静态资源编译进二进制文件中 - i18n国际化支持 - 支持类似Django的flatpages - SEO良好支持 使用 pink-lady/webserver 3 步组装一个 WEB 应用 1. 确认配置文件正确。 配置文件必须满足能解析出指定的内容，复制或修改 config.default.toml 中的配置项 2. 创建自定义中间件的 gin app NewGinEngine （可选） 3. 运行 web 应用服务器 Run 。 需传入 gin app 和在该 app 上注册 URL 路由注册函数 实现代码在 src 路径下，在 pink-lady 模板项目下，你只需关注如何实现你的业务逻辑，不用考虑如何组织项目结构和集成一些通用功能，比如数据库的连接封装，配置文件的读取，swagger 文档生成，统一的 JSON 返回结果，错误码定义，集成 Sentry 等等。 你可以在 routes 路径下实现你的 api，并在 routes/routes.go 的","default_branch":null,"files":null,"tree":[],"storefront":"/r/axiaoxin-com","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/axiaoxin-com/pink-lady/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}