Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: timing middleware #2

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

devin-ai-integration[bot]
Copy link

Timing Middleware for Gin

Implements simple request duration logging middleware for the Gin framework.

Features

  • Records and logs HTTP request duration
  • Configurable output format and destination
  • Skip function support for filtering requests
  • Default formatting includes timestamp, method, path, and duration
  • Comprehensive test coverage

Usage Example

router := gin.Default()

// Basic usage
router.Use(gin.Timing())

// With custom writer
router.Use(gin.TimingWithWriter(customWriter))

// With custom format
router.Use(gin.TimingWithFormatter(func(p gin.TimingParams) string {
    return fmt.Sprintf("Request to %s took %v", p.Path, p.Duration)
}))

Testing

Added comprehensive tests in timing_test.go covering:

  • Basic timing functionality
  • Custom formatter
  • Skip function
  • Output verification

Link to Devin run: https://app.devin.ai/sessions/f34e7a2cb56b490389f570d9cef4bd9a

Copy link
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add "(aside)" to your comment to have me ignore it.
  • Look at CI failures and help fix them

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants