Sen descrición

田欧 1d462bbe37 chore: update ginS (#1822) %!s(int64=7) %!d(string=hai) anos
.github 705e199298 chore: update issue_implate (#1524) %!s(int64=7) %!d(string=hai) anos
binding c16bfa7949 update for supporting file binding (#1264) %!s(int64=7) %!d(string=hai) anos
examples 05b5c3ba74 Doc: fix gin example notice syntax (#1814) %!s(int64=7) %!d(string=hai) anos
ginS 1d462bbe37 chore: update ginS (#1822) %!s(int64=7) %!d(string=hai) anos
internal a5dda62cdc chore: use internal/json (#1791) %!s(int64=7) %!d(string=hai) anos
render 7b1081a73f issue_1721: fix render writeHeaders to make it the same as http.Header.Set (#1722) %!s(int64=7) %!d(string=hai) anos
testdata 0c1f3c4e81 chore: fix invalid link (#1820) %!s(int64=7) %!d(string=hai) anos
vendor 0feaf8cbd8 Split examples to alone repo (#1776) %!s(int64=7) %!d(string=hai) anos
.gitignore cce49582d6 ci: break when test fail (#1671) %!s(int64=7) %!d(string=hai) anos
.travis.yml bcf36ade9f Remove sudo setting from travis.yml (#1816) %!s(int64=7) %!d(string=hai) anos
AUTHORS.md b869fe1415 docs: add changelog for v1.3.0, update authors and version const (#1478) %!s(int64=7) %!d(string=hai) anos
BENCHMARKS.md 74221b8a35 docs(benchmark): update benchmark data (#1035) %!s(int64=8) %!d(string=hai) anos
CHANGELOG.md b869fe1415 docs: add changelog for v1.3.0, update authors and version const (#1478) %!s(int64=7) %!d(string=hai) anos
CODE_OF_CONDUCT.md 22ee916dfe docs(conduct): add code of conduct %!s(int64=8) %!d(string=hai) anos
CONTRIBUTING.md 1923b35983 update document format. (#964) %!s(int64=8) %!d(string=hai) anos
LICENSE b6bd5b0d9f Add MIT license %!s(int64=11) %!d(string=hai) anos
Makefile 0feaf8cbd8 Split examples to alone repo (#1776) %!s(int64=7) %!d(string=hai) anos
README.md 0c1f3c4e81 chore: fix invalid link (#1820) %!s(int64=7) %!d(string=hai) anos
auth.go 6c6d97ba2e remove hardcode instead of http status value (#1411) %!s(int64=7) %!d(string=hai) anos
auth_test.go 6ab50f944c replace deprecated HeaderMap with Header() (#1585) %!s(int64=7) %!d(string=hai) anos
benchmarks_test.go f45c928a15 chore: use http.Status* instead of hard code (#1482) %!s(int64=7) %!d(string=hai) anos
codecov.yml 32cab500ec v1.1 (#751) %!s(int64=9) %!d(string=hai) anos
context.go 893c6cae07 Added stream flag indicates if client disconnected in middle of streaming (#1252) %!s(int64=7) %!d(string=hai) anos
context_17.go 29a145c85d Revert "context: inherits context cancelation and deadline from http.Request context for Go>=1.7 (#1690)" (#1736) %!s(int64=7) %!d(string=hai) anos
context_17_test.go 29a145c85d Revert "context: inherits context cancelation and deadline from http.Request context for Go>=1.7 (#1690)" (#1736) %!s(int64=7) %!d(string=hai) anos
context_appengine.go 4ad3baf44e Add license for some files (#940) %!s(int64=8) %!d(string=hai) anos
context_test.go ccb9e90295 Extend context.File to allow for the content-dispositon attachments via a new method context.Attachment (#1260) %!s(int64=7) %!d(string=hai) anos
debug.go 3d44ff82a1 Make sure the debug log contains line breaks (#1650) %!s(int64=7) %!d(string=hai) anos
debug_test.go 31bbb10f34 Make silent debug info on tests (#1765) %!s(int64=7) %!d(string=hai) anos
deprecated.go b1ee49de8c fix typo (#1103) %!s(int64=8) %!d(string=hai) anos
deprecated_test.go 31bbb10f34 Make silent debug info on tests (#1765) %!s(int64=7) %!d(string=hai) anos
doc.go 0c1f3c4e81 chore: fix invalid link (#1820) %!s(int64=7) %!d(string=hai) anos
errors.go 057f63b1bb spell check (#1796) %!s(int64=7) %!d(string=hai) anos
errors_test.go b056a34bdc fix errcheck warnings (#1739) %!s(int64=7) %!d(string=hai) anos
fs.go a8fa424ae5 update comment (#1057) %!s(int64=8) %!d(string=hai) anos
gin.go 057f63b1bb spell check (#1796) %!s(int64=7) %!d(string=hai) anos
gin_integration_test.go 5acf660117 fix travis freeze on concurrent test (#1761) %!s(int64=7) %!d(string=hai) anos
gin_test.go 31bbb10f34 Make silent debug info on tests (#1765) %!s(int64=7) %!d(string=hai) anos
githubapi_test.go e207a3ce65 Fix context.Copy() race condition (#1020) %!s(int64=7) %!d(string=hai) anos
go.mod df366c7840 chore: update go mod package (#1792) %!s(int64=7) %!d(string=hai) anos
go.sum df366c7840 chore: update go mod package (#1792) %!s(int64=7) %!d(string=hai) anos
logger.go b40d4c175c IsTerm flag should not be affected by DisableConsoleColor method. (#1802) %!s(int64=7) %!d(string=hai) anos
logger_test.go b40d4c175c IsTerm flag should not be affected by DisableConsoleColor method. (#1802) %!s(int64=7) %!d(string=hai) anos
middleware_test.go b056a34bdc fix errcheck warnings (#1739) %!s(int64=7) %!d(string=hai) anos
mode.go d7daffc26b Use camel case instead of ALL_CAPS (#1419) %!s(int64=7) %!d(string=hai) anos
mode_test.go d7daffc26b Use camel case instead of ALL_CAPS (#1419) %!s(int64=7) %!d(string=hai) anos
path.go 8fc8ce0472 small enhance for cleanPath (#1469) %!s(int64=7) %!d(string=hai) anos
path_test.go 1f59bad84b add an edge case from httprouter (#1407) %!s(int64=7) %!d(string=hai) anos
recovery.go 057f63b1bb spell check (#1796) %!s(int64=7) %!d(string=hai) anos
recovery_test.go 31bbb10f34 Make silent debug info on tests (#1765) %!s(int64=7) %!d(string=hai) anos
response_writer.go 0552c3bc3a flush operation will overwrite the origin status code (#1460) %!s(int64=7) %!d(string=hai) anos
response_writer_1.7.go bf85b32c1d Add Pusher() function for support http2 server push (#1273) %!s(int64=7) %!d(string=hai) anos
response_writer_1.8.go bf85b32c1d Add Pusher() function for support http2 server push (#1273) %!s(int64=7) %!d(string=hai) anos
response_writer_test.go b056a34bdc fix errcheck warnings (#1739) %!s(int64=7) %!d(string=hai) anos
routergroup.go 4a23c4f7b9 fix #1804 which is caused by calling middleware twice. (#1805) %!s(int64=7) %!d(string=hai) anos
routergroup_test.go f45c928a15 chore: use http.Status* instead of hard code (#1482) %!s(int64=7) %!d(string=hai) anos
routes_test.go 4a23c4f7b9 fix #1804 which is caused by calling middleware twice. (#1805) %!s(int64=7) %!d(string=hai) anos
test_helpers.go 7e64d32269 Attempt to fix #1462 (#1463) %!s(int64=7) %!d(string=hai) anos
tree.go a210eea3bd improve panic information when a catch-all wildcard conflict occurs (#1529) %!s(int64=7) %!d(string=hai) anos
tree_test.go 521d06c81d support bind uri param (#1612) %!s(int64=7) %!d(string=hai) anos
utils.go d510595aa5 chore: add some annotations (#1544) %!s(int64=7) %!d(string=hai) anos
utils_test.go f45c928a15 chore: use http.Status* instead of hard code (#1482) %!s(int64=7) %!d(string=hai) anos
version.go b27b7026c7 chore: add a version file includes gin version (#1549) %!s(int64=7) %!d(string=hai) anos

README.md

Gin Web Framework

Build Status codecov Go Report Card GoDoc Sourcegraph Open Source Helpers Release

Gin is a web framework written in Go (Golang). It features a martini-like API with much better performance, up to 40 times faster thanks to httprouter. If you need performance and good productivity, you will love Gin.

The key features of Gin are:

  • Zero allocation router
  • Fast
  • Middleware support
  • Crash-free
  • JSON validation
  • Routes grouping
  • Error management
  • Rendering built-in
  • Extendable

For more feature details, please see the Gin website introduction.

Getting started

Getting Gin

The first need Go installed (version 1.6+ is required), then you can use the below Go command to install Gin.

$ go get -u github.com/gin-gonic/gin

For more installation guides such as vendor tool, please check out Gin quickstart.

Running Gin

First you need to import Gin package for using Gin, one simplest example likes the follow example.go:

package main

import "github.com/gin-gonic/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
}

And use the Go command to run the demo:

# run example.go and visit 0.0.0.0:8080/ping on browser
$ go run example.go

Benchmarks

Please see all benchmarks details from Gin website.

Benchmark name (1) (2) (3) (4)
BenchmarkGin_GithubAll 30000 48375 0 0
BenchmarkAce_GithubAll 10000 134059 13792 167
BenchmarkBear_GithubAll 5000 534445 86448 943
BenchmarkBeego_GithubAll 3000 592444 74705 812
BenchmarkBone_GithubAll 200 6957308 698784 8453
BenchmarkDenco_GithubAll 10000 158819 20224 167
BenchmarkEcho_GithubAll 10000 154700 6496 203
BenchmarkGocraftWeb_GithubAll 3000 570806 131656 1686
BenchmarkGoji_GithubAll 2000 818034 56112 334
BenchmarkGojiv2_GithubAll 2000 1213973 274768 3712
BenchmarkGoJsonRest_GithubAll 2000 785796 134371 2737
BenchmarkGoRestful_GithubAll 300 5238188 689672 4519
BenchmarkGorillaMux_GithubAll 100 10257726 211840 2272
BenchmarkHttpRouter_GithubAll 20000 105414 13792 167
BenchmarkHttpTreeMux_GithubAll 10000 319934 65856 671
BenchmarkKocha_GithubAll 10000 209442 23304 843
BenchmarkLARS_GithubAll 20000 62565 0 0
BenchmarkMacaron_GithubAll 2000 1161270 204194 2000
BenchmarkMartini_GithubAll 200 9991713 226549 2325
BenchmarkPat_GithubAll 200 5590793 1499568 27435
BenchmarkPossum_GithubAll 10000 319768 84448 609
BenchmarkR2router_GithubAll 10000 305134 77328 979
BenchmarkRivet_GithubAll 10000 132134 16272 167
BenchmarkTango_GithubAll 3000 552754 63826 1618
BenchmarkTigerTonic_GithubAll 1000 1439483 239104 5374
BenchmarkTraffic_GithubAll 100 11383067 2659329 21848
BenchmarkVulcan_GithubAll 5000 394253 19894 609
  • (1): Total Repetitions achieved in constant time, higher means more confident result
  • (2): Single Repetition Duration (ns/op), lower is better
  • (3): Heap Memory (B/op), lower is better
  • (4): Average Allocations per Repetition (allocs/op), lower is better

Middlewares

You can find many useful Gin middlewares at gin-contrib.

Documentation

See API documentation and descriptions for package.

All documentation is available on the Gin website.

Examples

A number of ready-to-run examples demonstrating various use cases of Gin on the Gin examples repository.

Users

Gin website lists some awesome projects made with Gin web framework.

Contributing

Gin is the work of hundreds of contributors. We appreciate your help!

Please see CONTRIBUTING for details on submitting patches and the contribution workflow.