Exemplo n.º 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.",
		})
	}
}
Exemplo n.º 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))
}
Exemplo n.º 3
0
func handlerStatForContext(c *gin.Context) string {
	return fmt.Sprintf("http.%s.%s", strings.ToLower(c.Request.Method), statFromHandlerName(c.HandlerName()))
}