-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update newest doc from gin readme #49
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
9717a02
add npm package
thinkerou 4e2618d
Merge remote-tracking branch 'upstream/master'
thinkerou 3d402f5
Merge remote-tracking branch 'upstream/master'
thinkerou 09f356f
Merge remote-tracking branch 'upstream/master'
thinkerou b9736e0
Merge remote-tracking branch 'upstream/master'
thinkerou 99565ce
Merge remote-tracking branch 'upstream/master'
thinkerou bee4e50
Merge remote-tracking branch 'upstream/master'
thinkerou fea7b98
Merge remote-tracking branch 'upstream/master'
thinkerou 441ee04
Merge remote-tracking branch 'upstream/master'
thinkerou e491355
Merge remote-tracking branch 'upstream/master'
thinkerou 499d832
Merge remote-tracking branch 'upstream/master'
thinkerou c4798ae
Merge remote-tracking branch 'upstream/master'
thinkerou bd3e59d
Merge remote-tracking branch 'upstream/master'
thinkerou d10c611
Merge remote-tracking branch 'upstream/master'
thinkerou 8e16470
Merge remote-tracking branch 'upstream/master'
thinkerou 756ea90
change navbar color
thinkerou ae1fb75
Merge remote-tracking branch 'upstream/master'
thinkerou 3e0ce80
tmp: update name for saving git log from gin repo
thinkerou 28b0003
Merge remote-tracking branch 'upstream/master'
thinkerou a536691
fix conflict
thinkerou 028ea9f
Merge remote-tracking branch 'upstream/master'
thinkerou d452778
Merge remote-tracking branch 'upstream/master'
thinkerou e5ac246
update
thinkerou 4b87a4c
Merge remote-tracking branch 'upstream/master'
thinkerou 7e5d5c5
Merge remote-tracking branch 'upstream/master'
thinkerou ceaf1d4
sync update doc from gin
thinkerou File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# This viminfo file was generated by Vim 8.0. | ||
# You may edit it if you're careful! | ||
|
||
# Viminfo version | ||
|1,4 | ||
|
||
# Value of 'encoding' when this file was written | ||
*encoding=utf-8 | ||
|
||
|
||
# hlsearch on (H) or off (h): | ||
~h | ||
# Command Line History (newest to oldest): | ||
|
||
# Search String History (newest to oldest): | ||
|
||
# Expression History (newest to oldest): | ||
|
||
# Input Line History (newest to oldest): | ||
|
||
# Debug Line History (newest to oldest): | ||
|
||
# Registers: | ||
|
||
# File marks: | ||
'0 1 0 ~/go/src/github.com/gin-gonic/website/content/en/docs/examples/grep | ||
|4,48,1,0,1551702651,"~/go/src/github.com/gin-gonic/website/content/en/docs/examples/grep" | ||
|
||
# Jumplist (newest first): | ||
-' 1 0 ~/go/src/github.com/gin-gonic/website/content/en/docs/examples/grep | ||
|4,39,1,0,1551702651,"~/go/src/github.com/gin-gonic/website/content/en/docs/examples/grep" | ||
|
||
# History of marks within files (newest to oldest): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
content/en/docs/examples/controlling-log-output-coloring.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
title: "Controlling Log output coloring" | ||
draft: false | ||
--- | ||
|
||
By default, logs output on console should be colorized depending on the detected TTY. | ||
|
||
Never colorize logs: | ||
|
||
```go | ||
func main() { | ||
// Disable log's color | ||
gin.DisableConsoleColor() | ||
|
||
// Creates a gin router with default middleware: | ||
// logger and recovery (crash-free) middleware | ||
router := gin.Default() | ||
|
||
router.GET("/ping", func(c *gin.Context) { | ||
c.String(200, "pong") | ||
}) | ||
|
||
router.Run(":8080") | ||
} | ||
``` | ||
|
||
Always colorize logs: | ||
|
||
```go | ||
func main() { | ||
// Force log's color | ||
gin.ForceConsoleColor() | ||
|
||
// Creates a gin router with default middleware: | ||
// logger and recovery (crash-free) middleware | ||
router := gin.Default() | ||
|
||
router.GET("/ping", func(c *gin.Context) { | ||
c.String(200, "pong") | ||
}) | ||
|
||
router.Run(":8080") | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
title: "Custom log file" | ||
draft: false | ||
--- | ||
|
||
For example: | ||
|
||
```go | ||
func main() { | ||
router := gin.New() | ||
// LoggerWithFormatter middleware will write the logs to gin.DefaultWriter | ||
// By default gin.DefaultWriter = os.Stdout | ||
router.Use(gin.LoggerWithFormatter(func(param gin.LogFormatterParams) string { | ||
// your custom format | ||
return fmt.Sprintf("%s - [%s] \"%s %s %s %d %s \"%s\" %s\"\n", | ||
param.ClientIP, | ||
param.TimeStamp.Format(time.RFC1123), | ||
param.Method, | ||
param.Path, | ||
param.Request.Proto, | ||
param.StatusCode, | ||
param.Latency, | ||
param.Request.UserAgent(), | ||
param.ErrorMessage, | ||
) | ||
})) | ||
router.Use(gin.Recovery()) | ||
router.GET("/ping", func(c *gin.Context) { | ||
c.String(200, "pong") | ||
}) | ||
router.Run(":8080") | ||
} | ||
``` | ||
|
||
**Sample Output** | ||
``` | ||
::1 - [Fri, 07 Dec 2018 17:04:38 JST] "GET /ping HTTP/1.1 200 122.767µs "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.80 Safari/537.36" " | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,17 +4,13 @@ draft: false | |
weight: 2 | ||
--- | ||
|
||
- [Requirements](#requirements) | ||
- [Installation](#installation) | ||
- [Getting started](#getting-started) | ||
|
||
In this quickstart, we’ll glean insights from code segments and learn how to: | ||
|
||
## Requirements | ||
|
||
- Go 1.6 or above | ||
|
||
> Go 1.7 or Go 1.8 will be required soon. | ||
> Go 1.7 or Go 1.8 will be no longer supported soon. | ||
|
||
## Installation | ||
|
||
|
@@ -38,7 +34,7 @@ import "github.com/gin-gonic/gin" | |
import "net/http" | ||
``` | ||
|
||
#### Use a vendor tool like [Govendor](https://github.com/kardianos/govendor) | ||
### Use a vendor tool like [Govendor](https://github.com/kardianos/govendor) | ||
|
||
1. `go get` govendor | ||
|
||
|
@@ -61,7 +57,7 @@ $ govendor fetch github.com/gin-gonic/[email protected] | |
4. Copy a starting template inside your project | ||
|
||
```sh | ||
$ curl https://test2-for-worker.haf208.cc/gin-gonic/gin/master/examples/basic/main.go > main.go | ||
$ curl https://test2-for-worker.haf208.cc/gin-gonic/examples/master/basic/main.go > main.go | ||
``` | ||
|
||
5. Run your project | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing file extension?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@appleboy thanks! invalid file, I remove it!