# Gin Web Framework
<img align="right" width="159px" src="https://raw.githubusercontent.com/gin-gonic/logo/master/color.png">
[![Build Status](https://travis-ci.org/gin-gonic/gin.svg)](https://travis-ci.org/gin-gonic/gin)
[![codecov](https://codecov.io/gh/gin-gonic/gin/branch/master/graph/badge.svg)](https://codecov.io/gh/gin-gonic/gin)
[![Go Report Card](https://goreportcard.com/badge/github.com/gohade/hade/framework/gin)](https://goreportcard.com/report/github.com/gohade/hade/framework/gin)
[![GoDoc](https://pkg.go.dev/badge/github.com/gohade/hade/framework/gin?status.svg)](https://pkg.go.dev/github.com/gohade/hade/framework/gin?tab=doc)
[![Join the chat at https://gitter.im/gin-gonic/gin](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/gin-gonic/gin?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Sourcegraph](https://sourcegraph.com/github.com/gohade/hade/framework/gin/-/badge.svg)](https://sourcegraph.com/github.com/gohade/hade/framework/gin?badge)
[![Open Source Helpers](https://www.codetriage.com/gin-gonic/gin/badges/users.svg)](https://www.codetriage.com/gin-gonic/gin)
[![Release](https://img.shields.io/github/release/gin-gonic/gin.svg?style=flat-square)](https://github.com/gohade/hade/framework/gin/releases)
[![TODOs](https://badgen.net/https/api.tickgit.com/badgen/github.com/gohade/hade/framework/gin)](https://www.tickgit.com/browse?repo=github.com/gohade/hade/framework/gin)
Gin is a web framework written in Go (Golang). It features a martini-like API with performance that is up to 40 times faster thanks to [httprouter](https://github.com/julienschmidt/httprouter). If you need performance and good productivity, you will love Gin.
## Contents
- [Gin Web Framework](#gin-web-framework)
- [Contents](#contents)
- [Installation](#installation)
- [Quick start](#quick-start)
- [Benchmarks](#benchmarks)
- [Gin v1. stable](#gin-v1-stable)
- [Build with jsoniter](#build-with-jsoniter)
- [API Examples](#api-examples)
- [Using GET, POST, PUT, PATCH, DELETE and OPTIONS](#using-get-post-put-patch-delete-and-options)
- [Parameters in path](#parameters-in-path)
- [Querystring parameters](#querystring-parameters)
- [Multipart/Urlencoded Form](#multiparturlencoded-form)
- [Another example: query + post form](#another-example-query--post-form)
- [Map as querystring or postform parameters](#map-as-querystring-or-postform-parameters)
- [Upload files](#upload-files)
- [Single file](#single-file)
- [Multiple files](#multiple-files)
- [Grouping routes](#grouping-routes)
- [Blank Gin without middleware by default](#blank-gin-without-middleware-by-default)
- [Using middleware](#using-middleware)
- [How to write log file](#how-to-write-log-file)
- [Custom Log Format](#custom-log-format)
- [Controlling Log output coloring](#controlling-log-output-coloring)
- [Model binding and validation](#model-binding-and-validation)
- [Custom Validators](#custom-validators)
- [Only Bind Query String](#only-bind-query-string)
- [Bind Query String or Post Data](#bind-query-string-or-post-data)
- [Bind Uri](#bind-uri)
- [Bind Header](#bind-header)
- [Bind HTML checkboxes](#bind-html-checkboxes)
- [Multipart/Urlencoded binding](#multiparturlencoded-binding)
- [XML, JSON, YAML and ProtoBuf rendering](#xml-json-yaml-and-protobuf-rendering)
- [SecureJSON](#securejson)
- [JSONP](#jsonp)
- [AsciiJSON](#asciijson)
- [PureJSON](#purejson)
- [Serving static files](#serving-static-files)
- [Serving data from file](#serving-data-from-file)
- [Serving data from reader](#serving-data-from-reader)
- [HTML rendering](#html-rendering)
- [Custom Template renderer](#custom-template-renderer)
- [Custom Delimiters](#custom-delimiters)
- [Custom Template Funcs](#custom-template-funcs)
- [Multitemplate](#multitemplate)
- [Redirects](#redirects)
- [Custom Middleware](#custom-middleware)
- [Using BasicAuth() middleware](#using-basicauth-middleware)
- [Goroutines inside a middleware](#goroutines-inside-a-middleware)
- [Custom HTTP configuration](#custom-http-configuration)
- [Support Let's Encrypt](#support-lets-encrypt)
- [Run multiple service using Gin](#run-multiple-service-using-gin)
- [Graceful shutdown or restart](#graceful-shutdown-or-restart)
- [Third-party packages](#third-party-packages)
- [Manually](#manually)
- [Build a single binary with templates](#build-a-single-binary-with-templates)
- [Bind form-data request with custom struct](#bind-form-data-request-with-custom-struct)
- [Try to bind body into different structs](#try-to-bind-body-into-different-structs)
- [http2 server push](#http2-server-push)
- [Define format for the log of routes](#define-format-for-the-log-of-routes)
- [Set and get a cookie](#set-and-get-a-cookie)
- [Testing](#testing)
- [Users](#users)
## Installation
To install Gin package, you need to install Go and set your Go workspace first.
1. The first need [Go](https://golang.org/) installed (**version 1.12+ is required**), then you can use the below Go command to install Gin.
```sh
$ go get -u github.com/gohade/hade/framework/gin
```
2. Import it in your code:
```go
import "github.com/gohade/hade/framework/gin"
```
3. (Optional) Import `net/http`. This is required for example if using constants such as `http.StatusOK`.
```go
import "net/http"
```
## Quick start
```sh
# assume the following codes in example.go file
$ cat example.go
```
```go
package main
import "github.com/gohade/hade/framework/gin"
func main() {
r := gin.Default()
r.GET("/ping", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "pong",
})
})
r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
}
```
```
# run example.go and visit 0.0.0.0:8080/ping (for windows "localhost:8080/ping") on browser
$ go run example.go
```
## Benchmarks
Gin uses a custom version of [HttpRouter](https://github.com/julienschmidt/httprouter)
[See all benchmarks](/BENCHMARKS.md)
| Benchmark name | (1) | (2) | (3) | (4) |
| ------------------------------ | --------: | --------------: | -----------: | --------------: |
| BenchmarkGin_GithubAll | **43550** | **27364 ns/op** | **0 B/op** | **0 allocs/op** |
| BenchmarkAce_GithubAll | 40543 | 29670 ns/op | 0 B/op | 0 allocs/op |
| BenchmarkAero_GithubAll | 57632 | 20648 ns/op | 0 B/op | 0 allocs/op |
| BenchmarkBear_GithubAll | 9234 | 216179 ns/op | 86448 B/op | 943 allocs/op |
| BenchmarkBeego_GithubAll | 7407 | 243496 ns/op | 71456 B/op | 609 allocs/op |
| BenchmarkBone_GithubAll | 420 | 2922835 ns/op | 720160 B/op | 8620 allocs/op |
| BenchmarkChi_GithubAll | 7620 | 238331 ns/op | 87696 B/op | 609 allocs/op |
| BenchmarkDenco_GithubAll | 18355 | 64494 ns/op | 20224 B/op | 167 allocs/op |
| BenchmarkEcho_GithubAll | 31251 | 38479 ns/op | 0 B/op | 0 allocs/op |
| BenchmarkGocraftWeb_GithubAll | 4117 | 300062 ns/op | 131656 B/op | 1686 allocs/op |
| BenchmarkGoji_GithubAll | 3274 | 416158 ns/op | 56112 B/op | 334 allocs/op |
| BenchmarkGojiv2_GithubAll | 1402 | 870518 ns/op | 352720 B/op | 4321 allocs/op |
| BenchmarkGoJsonRest_GithubAll | 2976 | 401507 ns/op | 134371 B/op | 2737 allocs/op |
| BenchmarkGoRestful_GithubAll | 410 | 2913158 ns/op | 910144 B/op | 2938 allocs/op |
| BenchmarkGorillaMux_GithubAll | 346 | 3384987 ns/op | 251650 B/op | 1994 allocs/op |
| BenchmarkGowwwRouter_GithubAll | 10000 | 143025 ns/op | 72144 B/op | 501 allocs/op |
| BenchmarkHttpRouter_GithubAll | 55938 | 21360 ns/op | 0 B/op | 0 a
没有合适的资源?快使用搜索试试~ 我知道了~
hade 框架,快速开发应用.zip
共433个文件
go:309个
md:55个
yaml:20个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 174 浏览量
2024-02-08
21:40:02
上传
评论
收藏 6.88MB ZIP 举报
温馨提示
快应用开发
资源推荐
资源详情
资源评论
收起资源包目录
hade 框架,快速开发应用.zip (433个子文件)
.editorconfig 147B
.eslintrc 58B
.gitignore 484B
.gitignore 313B
.gitignore 211B
.gitignore 77B
.gitkeep 0B
.gitkeeper 0B
.gitkeeper 0B
b0xfile__swagger-ui-bundle.js.map.go 42.87MB
b0xfile__swagger-ui-standalone-preset.js.map.go 8.46MB
b0xfile__swagger-ui.js.map.go 8.26MB
b0xfile__swagger-ui-bundle.js.go 5.8MB
b0xfile__swagger-ui.js.go 1.3MB
b0xfile__swagger-ui-standalone-preset.js.go 1.26MB
b0xfile__swagger-ui.css.go 133KB
completions_test.go 70KB
context_test.go 61KB
command_test.go 54KB
command.go 47KB
context.go 36KB
license_gpl_3.go 36KB
binding_test.go 35KB
license_agpl.go 35KB
tree_test.go 29KB
completions.go 29KB
bash_completions.go 21KB
tree.go 21KB
license_gpl_2.go 19KB
gin_integration_test.go 18KB
api_gen.go 18KB
routes_test.go 18KB
gin.go 18KB
githubapi_test.go 17KB
gin_test.go 16KB
b0xfile__index.html.go 14KB
logger_test.go 13KB
render_test.go 13KB
app.go 13KB
license_apache_2.go 12KB
deploy.go 12KB
powershell_completions.go 10KB
dev.go 10KB
bash_completionsV2.go 10KB
new.go 9KB
bash_completions_test.go 9KB
service.go 9KB
zsh_completions.go 9KB
form_mapping.go 9KB
b0xfile__oauth2-redirect.html.go 8KB
license_lgpl.go 8KB
routergroup.go 8KB
fish_completions.go 8KB
helloworld.pb.go 8KB
man_docs.go 7KB
api_gen_test.go 7KB
form_mapping_test.go 7KB
swagger.go 7KB
recovery_test.go 7KB
logger.go 7KB
args_test.go 7KB
cobra.go 7KB
hade_request.go 7KB
provider.go 6KB
man_docs_test.go 6KB
service.go 6KB
start.go 6KB
cron.go 6KB
gins.go 5KB
middleware.go 5KB
validate_test.go 5KB
rest_docs.go 5KB
api.go 5KB
redis.go 5KB
middleware_test.go 5KB
recovery.go 5KB
b0xfile__favicon-32x32.png.go 5KB
debug_test.go 5KB
json.go 5KB
yaml_docs.go 5KB
cors_test.go 5KB
container.go 5KB
gen.go 5KB
memory.go 5KB
md_docs.go 5KB
routergroup_test.go 5KB
helloworld_grpc.pb.go 4KB
docs.go 4KB
errors.go 4KB
main.go 4KB
service.go 4KB
log.go 4KB
binding.go 4KB
orm.go 4KB
benchmarks_test.go 4KB
version.go 4KB
utils_test.go 4KB
license_bsd_clause_3.go 4KB
hade_response.go 4KB
auth_test.go 4KB
共 433 条
- 1
- 2
- 3
- 4
- 5
资源评论
博士僧小星
- 粉丝: 1931
- 资源: 5897
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于多种编程语言的Jugg后台管理系统设计源码
- java进销存管理系统(jsp+mssql).rar
- tensorflow-2.9.3-cp310-cp310-win-amd64.whl
- tensorflow-2.9.2-cp310-cp310-win-amd64.whl
- 2000-2021年各地级市普通高等学校在校学生数数据.xls
- tensorflow-gpu-2.9.2-cp310-cp310-win-amd64.whl
- 2000-2021年各地级市人力资本水平数据(含原始数据+计算过程+计算结果).xlsx
- WX小程序源码无后台weapp-360che-master
- 基于Android的水产养殖管理系统设计源码
- demo_LADRC_simulink.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功