Skip to content

Comments

feat/resources#4

Merged
isaacwallace123 merged 7 commits intomasterfrom
feat/resources
Aug 8, 2025
Merged

feat/resources#4
isaacwallace123 merged 7 commits intomasterfrom
feat/resources

Conversation

@isaacwallace123
Copy link
Owner

Basically, I added support for config files. So now we can start making pre-built recognizable config names similar to spring to allow users to better configure their API to their liking.

I also added support for static resources such as /public routes and /static routes that will forward things such as css code, html, js, images, and so on.

I also updated the dependency version for GoUtils that we are using from v1.0.1 to v1.0.2.

I also opted in removing static handling as a middleware and decided to have it just natively supported by the router using the new "UseStatic" method.

Is there anything I'm missing or should verify before pushing this to main?

… /public or any static resource location, added static types in types folder, added config engine to handle configs
…iddleware), create UseStatic method to add a static path to the router, modified router Listen Implementation to offer more control for users to create custom routes
@isaacwallace123 isaacwallace123 added the help wanted Extra attention is needed label Aug 1, 2025
func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
for _, handler := range r.resources {
if handler(w, req) {
return
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I understand this is to return the static resource and break the flow so that it doesn't try dynamic route, it doesn't break the ServeHTTP flow right? (I assumed this didn't do anything and you were missing something lol)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this would break the typical dispatch to then serve the static resource instead. However, I'm thinking of maybe incorporating static resources more in dispatch rather than the servlet. What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dispatch would make more sense, however it depends how dispatch is handled. If dispatch does any other extra processing, then maybe it would be best to keep it in the servlet as it doesn't exhaust more resources than it needs to since it's just serving a static resource.

Copy link
Collaborator

@viktorkuts viktorkuts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, however what format does the config file need to be? I assume this will be added later (the parsing part right?)

@isaacwallace123
Copy link
Owner Author

The configs as of right now only support .json format. It doesn't support yml yet because GoLang doesn't support yml natively, so we either make our own parser or we use a pre-made parser and I'm not sure which approach to go for. Can you offer some insight?

@viktorkuts
Copy link
Collaborator

The configs as of right now only support .json format. It doesn't support yml yet because GoLang doesn't support yml natively, so we either make our own parser or we use a pre-made parser and I'm not sure which approach to go for. Can you offer some insight?

I'm more for using a parser that already exists as we don't have to go through the internals of each file standard and dealing with the file logistics, but I'll take a look at what exists with Go, if it doesn't exist or doesn't run really well, then we should make our own.

@isaacwallace123 isaacwallace123 merged commit 4a4d0a2 into master Aug 8, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

help wanted Extra attention is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants