Using r.Use causes middleware to be hit on every request

Open
#49 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
go
Domain
backend

Research direction

Start by tracing how app.Use(static.Serve()) invokes the static middleware and how the URL passed to .Serve is evaluated. Check the middleware's existing behavior and tests, then define the expected request matching and logging behavior before making a change. Done means requests outside the configured static URL no longer invoke that middleware unnecessarily.

Written by the indexing model from the issue text.

Description

When using the middleware as

app.Use(static.Serve())

Every request first hits the static middleware which causes errors to show up on in the logs indicating that the specified files do not exist.

Is there a better way to use the static middleware with its own middleware as well so it only gets hit when the request matches the url passed to the .Serve function?

Dominant language
Go
Stars
321
Forks
44
Avg merge
3d 3h
Merged PRs (30d)
2

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from gin-contrib/static

All issues in gin-contrib/static

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.