Skip to content
Snippets Groups Projects
Select Git revision
  • 9e1d5a059a1867d582391ae019b68f2696f8f0e8
  • master default protected
  • v1.4.5
  • v1.4.4
  • v1.4.3
  • v1.4.2
  • v1.4.1
  • v1.4.0
  • v1.3.10
  • v1.3.9
  • v1.3.8
  • v1.3.7
  • v1.3.6
  • v1.3.5
  • v1.3.4
  • v1.3.3
  • v1.3.2
  • v1.3.1
  • v1.3.0
  • v1.2.9
  • v1.2.8
  • v1.2.7
22 results

recover.go

Blame
  • recover.go 436 B
    package main
    
    import (
    	"fmt"
    	"github.com/gin-gonic/gin"
    	"log"
    	"net/http"
    	"runtime/debug"
    )
    
    func recovery() gin.HandlerFunc {
    	return func(context *gin.Context) {
    		defer func() {
    			p := recover()
    			if p != nil {
    				log.Printf("panic in web server %s", p)
    				context.JSON(http.StatusInternalServerError, gin.H{
    					"error": "panic in web server",
    				})
    				fmt.Println(string(debug.Stack()))
    			}
    		}()
    		context.Next()
    	}
    }