mirror of
https://github.com/gin-gonic/gin.git
synced 2025-11-16 08:22:10 +08:00
docs(README): add a Trivy security scan badge (#4426)
- Add a Trivy security scan badge to the documentation - Import the log package in the example code - Improve error handling for server startup in the example code Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
5e5ff3ace4
commit
dceb61e6e7
11
README.md
11
README.md
@ -3,6 +3,7 @@
|
||||
<img align="right" width="159px" src="https://raw.githubusercontent.com/gin-gonic/logo/master/color.png">
|
||||
|
||||
[](https://github.com/gin-gonic/gin/actions/workflows/gin.yml)
|
||||
[](https://github.com/gin-gonic/gin/actions/workflows/trivy-scan.yml)
|
||||
[](https://codecov.io/gh/gin-gonic/gin)
|
||||
[](https://goreportcard.com/report/github.com/gin-gonic/gin)
|
||||
[](https://pkg.go.dev/github.com/gin-gonic/gin?tab=doc)
|
||||
@ -62,6 +63,7 @@ Here's a complete example that demonstrates Gin's simplicity:
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@ -70,7 +72,7 @@ import (
|
||||
func main() {
|
||||
// Create a Gin router with default middleware (logger and recovery)
|
||||
r := gin.Default()
|
||||
|
||||
|
||||
// Define a simple GET endpoint
|
||||
r.GET("/ping", func(c *gin.Context) {
|
||||
// Return JSON response
|
||||
@ -78,10 +80,12 @@ func main() {
|
||||
"message": "pong",
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
// Start server on port 8080 (default)
|
||||
// Server will listen on 0.0.0.0:8080 (localhost:8080 on Windows)
|
||||
r.Run()
|
||||
if err := r.Run(); err != nil {
|
||||
log.Fatalf("failed to run server: %v", err)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@ -190,7 +194,6 @@ Gin has a rich ecosystem of middleware for common web development needs. Explore
|
||||
- CORS, Rate limiting, Compression
|
||||
- Logging, Metrics, Tracing
|
||||
- Static file serving, Template engines
|
||||
|
||||
- **[gin-gonic/contrib](https://github.com/gin-gonic/contrib)** - Additional community middleware
|
||||
|
||||
## 🏢 Production Usage
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user