gorilla / mux

Package gorilla/mux is a powerful HTTP router and URL matcher for building Go web servers with 🦍

Home Page:https://gorilla.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[question] How to handle invalid paths for Logging Purposes.

ACodingGenie opened this issue · comments

Hi, so I'm attempting to design a few endpoints for my API in Go using Gorilla Mux but the issue I'm running into is handling invalid paths for logging. Currently, I use a regex as shown in the screenshot below for invalid paths but this won't capture all the invalid routes. It only captures until the next '/'. I would like for it be able to capture all paths no matter the length or how ever many '/' there are. I realize it returns a 404 status code, but I can't log it. I would rather return that 404 code myself and log it while doing so. Is this something possible to do with Mux? Thanks.

Versions

Go version: go version 1.15.3

Screenshot of Code
image

How did you solve this?

@muety I just kept it as is. Let me know if you'd like me to reopen the issue.