From 2e3ad7b47bde1c9db5f834341f7b1444119ace7b Mon Sep 17 00:00:00 2001 From: Jenifar <76559684+brusooo@users.noreply.github.com> Date: Wed, 14 Feb 2024 14:05:25 +0530 Subject: [PATCH] --feat added net/http package code in _index.md --- content/en/docs/quickstart/_index.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/content/en/docs/quickstart/_index.md b/content/en/docs/quickstart/_index.md index f8549bb19..d8ea54855 100644 --- a/content/en/docs/quickstart/_index.md +++ b/content/en/docs/quickstart/_index.md @@ -85,3 +85,28 @@ And, You can run the code via `go run example.go`: # run example.go and visit 0.0.0.0:8080/ping on browser $ go run example.go ``` + +If you prefer to use the `net/http` package, follow the code snippet below + +```go + +package main + +import ( + "github.com/gin-gonic/gin" + "net/http" +) + +func main() { + r := gin.Default() + + r.GET("/ping", func(c *gin.Context) { + c.JSON(http.StatusOK, gin.H{ + "message": "pong", + }) + }) + + r.Run() // listen and serve on 0.0.0.0:8080 +} + +```