Skip to content
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

debug模式下,支持json语法高亮 #78

Closed
guonaihong opened this issue Oct 31, 2019 · 0 comments
Closed

debug模式下,支持json语法高亮 #78

guonaihong opened this issue Oct 31, 2019 · 0 comments

Comments

@guonaihong
Copy link
Owner

@guonaihong guonaihong commented Oct 31, 2019

Debug函数传入gout.DebugColor(),就可以打开颜色高亮功能。

package main

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"github.com/guonaihong/gout"
	"time"
)

func server() {
	router := gin.Default()
	router.POST("/colorjson", func(c *gin.Context) {
		c.JSON(200, gin.H{"str2": "str2 val", "int2": 2})
	})

	router.Run()
}
func main() {
	go server()

	time.Sleep(time.Millisecond * 500)

	err := gout.POST(":8080/colorjson").
		Debug(true). //可以使用gout.NoColor() 输出没有颜色高亮的debug信息
		SetJSON(gout.H{"str": "foo",
			"num":   100,
			"bool":  false,
			"null":  nil,
			"array": gout.A{"foo", "bar", "baz"},
			"obj":   gout.H{"a": 1, "b": 2},
		}).Do()

	if err != nil {
		fmt.Printf("err = %v\n", err)
	}
}
@guonaihong guonaihong added the v0.0.3 label Oct 31, 2019
guonaihong added a commit that referenced this issue Nov 1, 2019
guonaihong added a commit that referenced this issue Nov 1, 2019
guonaihong added a commit that referenced this issue Nov 2, 2019
guonaihong added a commit that referenced this issue Nov 2, 2019
guonaihong added a commit that referenced this issue Nov 4, 2019
guonaihong added a commit that referenced this issue Nov 5, 2019
guonaihong added a commit that referenced this issue Nov 6, 2019
guonaihong added a commit that referenced this issue Nov 6, 2019
Color json #78 #82
@guonaihong guonaihong closed this Nov 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.