Golang Context.HandlerName Examples

Golang Context.HandlerName - 3 examples found. These are the top rated real world Golang examples of github.com/gin-gonic/gin.Context.HandlerName extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
func handleUnrouted(c *gin.Context) {
	c.Next()
	if c.HandlerName() == "main.handleUnrouted" {
		c.JSON(http.StatusNotFound, gin.H{
			"error":   http.StatusNotFound,
			"message": "Route not found.",
		})
	}
}
Example #2
0
func SQLStatForContext(c *gin.Context, suffix string) string {

	stat := fmt.Sprintf("sql.%s", statFromHandlerName(c.HandlerName()))
	if len(suffix) == 0 {
		return stat
	}

	return fmt.Sprintf("%s.%s", stat, sanitizeSQLSuffix(suffix))
}
Example #3
0
func handlerStatForContext(c *gin.Context) string {
	return fmt.Sprintf("http.%s.%s", strings.ToLower(c.Request.Method), statFromHandlerName(c.HandlerName()))
}