-
Notifications
You must be signed in to change notification settings - Fork 0
feat/resources #4
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3489431
Added config support with .json format, added static files to support…
isaacwallace123 4d2256b
Updated gitgnore
isaacwallace123 c693109
Removed static middleware (It should be built into router and not a m…
isaacwallace123 e96aeb3
Updated GoUtils version being used and updated logging to also log st…
isaacwallace123 43f011b
Updated README.MD with supporting documentation for configuration
isaacwallace123 a06bc2c
Added more context to README.MD for better documentation
isaacwallace123 98ba191
Fixed tabbing issues on README.MD
isaacwallace123 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,4 +2,6 @@ | |
| dev/ | ||
| main.go | ||
| GoWeb | ||
| Makefile | ||
| Makefile | ||
| public/ | ||
| static/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| package config | ||
|
|
||
| import ( | ||
| "github.com/isaacwallace123/GoUtils/jsonutil" | ||
| "github.com/isaacwallace123/GoWeb/app/types" | ||
| "os" | ||
| "strconv" | ||
| ) | ||
|
|
||
| type ServerConfig struct { | ||
| Port int `json:"port"` | ||
| } | ||
|
|
||
| var ( | ||
| Server ServerConfig | ||
| Static []types.StaticConfig | ||
| ) | ||
|
|
||
| type appConfig struct { | ||
| Server ServerConfig `json:"server"` | ||
| Static []types.StaticConfig `json:"static"` | ||
| } | ||
|
|
||
| func LoadConfig(path string) error { | ||
| file, err := os.ReadFile(path) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| var loaded appConfig | ||
| if err := jsonutil.FromBytes(file, &loaded); err != nil { | ||
| return err | ||
| } | ||
| Server = loaded.Server | ||
| Static = loaded.Static | ||
| return nil | ||
| } | ||
|
|
||
| // PortString returns ":8080" (or whatever garbage port you configured) | ||
| func PortString() string { | ||
| return ":" + strconv.Itoa(Server.Port) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package types | ||
|
|
||
| type StaticConfig struct { | ||
| Path string `json:"path"` | ||
| Directory string `json:"directory"` | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| github.com/isaacwallace123/GoUtils v1.0.1 h1:XGG8zKeG+K/mWf6NQw1KIOppiz9WyxHuGVvFuc4MWC0= | ||
| github.com/isaacwallace123/GoUtils v1.0.1/go.mod h1:7SX/JIf8Zdml2dh6Zn6vNSrEsYlXwlkLzU8o85UG3Rk= | ||
| github.com/isaacwallace123/GoUtils v1.0.2 h1:CrWqtcuuWU6DxNWSbf5bkOGiZsILQvnNasvADYfgle4= | ||
| github.com/isaacwallace123/GoUtils v1.0.2/go.mod h1:7SX/JIf8Zdml2dh6Zn6vNSrEsYlXwlkLzU8o85UG3Rk= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.