Conversation
… /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
| func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) { | ||
| for _, handler := range r.resources { | ||
| if handler(w, req) { | ||
| return |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
viktorkuts
left a comment
There was a problem hiding this comment.
Looks good, however what format does the config file need to be? I assume this will be added later (the parsing part right?)
|
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. |
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?