Conversation
mathisve
commented
Oct 4, 2020
- Added the /V1/bump endpoint
- Added the temporary JSON Store ("database")
- Added /V1/bump endpoint documentation
blacksmithop
left a comment
There was a problem hiding this comment.
API looks good, I'm up for merging.
Travis-Owens
left a comment
There was a problem hiding this comment.
@Mathisco-01, Overall great job on the code in this commit.
There are a few consistent issues throughout the commit:
- Non-descriptive variable naming
- Inconsistent indentation (editor settings?)
- General lack of detailed comments
As this project progresses, I think we'll want to make commits much smaller and more focused on individual task. However, at the beginner there is just a lot of framework related task to contend with that bloat commit scopes.
|
|
||
| const ( | ||
| PORT = ":8080" | ||
| BUMP_INTERVAL = 60 // 1 minute in seconds |
There was a problem hiding this comment.
Inconsistent indentation
| log.Print(err) | ||
| } else { | ||
| log.Print("'Database' successfully restored!") | ||
| log.Print(fmt.Sprintf("%v guilds in 'database'", len(gs.Guilds))) |
There was a problem hiding this comment.
Inconsistent indentation
| return | ||
| } | ||
|
|
||
| if !gs.GuildInStore(guild) { |
There was a problem hiding this comment.
if { if { if { }}} Can this be simplified?
| func HandleRequests() { | ||
| router := mux.NewRouter().StrictSlash(true) | ||
| router.HandleFunc("/V1/bump", middleware(BumpGuild)).Methods("POST") | ||
| log.Print(fmt.Sprintf("Now serving: localhost%s", PORT)) |
There was a problem hiding this comment.
Inconsistent indentation
| router := mux.NewRouter().StrictSlash(true) | ||
| router.HandleFunc("/V1/bump", middleware(BumpGuild)).Methods("POST") | ||
| log.Print(fmt.Sprintf("Now serving: localhost%s", PORT)) | ||
| err := http.ListenAndServe(PORT, router) |
There was a problem hiding this comment.
Inconsistent indentation
|
|
||
| func LoadStore() (guilds []Guild, err error) { | ||
| // Open store.json file | ||
| file, err := os.OpenFile(STORE_FILE_NAME, os.O_CREATE, 0644) |
There was a problem hiding this comment.
Inconsistent indentation
| } | ||
|
|
||
| // Read file into contents | ||
| contents, err := ioutil.ReadAll(file) |
There was a problem hiding this comment.
Inconsistent indentation
|
|
||
| gs.Guilds = sortGuilds(gs.Guilds) | ||
|
|
||
| g, err := json.Marshal(gs.Guilds) |
| return err | ||
| } | ||
|
|
||
| func sortGuilds(guilds []Guild) []Guild { |
There was a problem hiding this comment.
Comments? What purpose does this function accomplish?
| return guilds | ||
| } | ||
|
|
||
| func (gs *GuildStore) GuildInStore(guild Guild) (bool) { |
There was a problem hiding this comment.
Add some comments to explain the difference between GuildStore and storedGuild
There was a problem hiding this comment.
This reminded me of the fact that since I do not work in Go, my approvals will mostly be based on how I could interact it with the api in my local setup. I'd suggest having someone who does work with Go to approve future PR's.