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 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)
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant