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: add wrapper for default not found handler #8

Merged
merged 1 commit into from
Jan 24, 2024
Merged

Conversation

vividvilla
Copy link
Member

Added a new wrapper for fasthttprouter default not found method - Router.NotFound.

@iraycd
Copy link

iraycd commented Sep 13, 2022

Sorry for being involved in this thread; I was curious to know why everything is in a single file.

Although it's a wrapper around fasthttp, I think this have to be in a separate file so it is lossy coupled and can be tested independently.

@knadh
Copy link
Contributor

knadh commented Sep 14, 2022

Sorry, a bit confused by this. Are you referring to fastglue.go?

It's a tiny file with a couple hundred lines of code and a similar number of comments. Go does not treat files as modules like Javascript or Python does (and typically compiles all files in a package together in the same namespace), so when it comes to execution and testing, it does not matter whether the code is in one file or split across multiple files.

@iraycd
Copy link

iraycd commented Sep 15, 2022

@knadh Yeah, I was talking about fastglue.go

Thank you for the response. I just had a doubt.

Yeah, I agree with you as it has less number of lines and testing parts.

I understand how namespace, separates files and is also human-readable, and the splitting is for the organization.

What I was seeing was something like this:
For example, SendString, SendString and SendJSON can be in something like ctx.go and which carries the same namespace.

In test was suggesting something similar to this:
https://github.com/gofiber/fiber/blob/master/path_test.go

The approach which is common for many modules and wrappers built around fasthttp

@knadh
Copy link
Contributor

knadh commented Sep 15, 2022

I don't think that's necessary @iraycd. Splitting files is subjective and we're talking about tiny, ~5 line functions here in a tiny package. Something like ctx.go would be arbitrary. If anything, it should be something like response.go because these are response handler functions. However, like I said, these are tiny functions and there's no benefit to moving them to a new file.

@knadh knadh merged commit e80eb9b into master Jan 24, 2024
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.

3 participants