-
Notifications
You must be signed in to change notification settings - Fork 127
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
MM-51188 Use mux.Router #923
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #923 +/- ##
==========================================
+ Coverage 29.96% 31.01% +1.05%
==========================================
Files 49 50 +1
Lines 7520 7383 -137
==========================================
+ Hits 2253 2290 +37
+ Misses 5078 4907 -171
+ Partials 189 186 -3
... and 1 file with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
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.
LGTM! One minor/non-blocking comment: I was torn between the prefixed router or the full route names as approaches, but not a both have their pros and cons, so 0/5 on it.
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.
Neat 🚀
There are some method check accross the repo like in
mattermost-plugin-jira/server/issue.go
Lines 172 to 175 in 2f8fa78
if r.Method != http.MethodPost { | |
return respondErr(w, http.StatusMethodNotAllowed, | |
errors.New("method "+r.Method+" is not allowed, must be POST")) | |
} |
return | ||
} | ||
|
||
status, err := fn(w, r, callbackInstanceID) |
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.
Nit pick: Can handleResponse
be used here with an adapter?
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.
@hanzei, can you please elaborate?
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.
By replacing this line and the following with
status, err := fn(w, r, callbackInstanceID) | |
p.handleResponse(func(w http.ResponseWriter, r *http.Request) (int, error) { | |
return fn(w, r, callbackInstanceID) | |
}) |
we estimate the duplicate code that takes care of the status code..
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.
Got it. Makes sense 👍 Updated the code now.
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.
@hanzei the suggested logic would not work, as the underlying functions being called were not getting the expected callbackInstanceID. Hence instead of this, I have now added a common function to parse the status and the error and log them from a single function instead of writing duplicate code. Hope this is fine.
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.
Great improvement here 👍
Just a few suggestions
@hanzei @mickmister, I have implemented the review comments and some additional findings like using |
@srkgupta I may be mistaken but I believe something is broken here. When I try to smoke test by installing a cloud instance, the Please let me know if you can reproduce this or perhaps there is some unrelated cause I have overlooked. Steps:
|
Thanks @DHaussermann for catching this issue. I have fixed the issue and pushed a new commit. It should resolve the issue. Can you please specifically check the entire OAuth1 & the Connection flows. The HTTP methods for some of these API endpoints were not clearly defined previously. Hence any HTTP method like GET, POST request would work. However with the new mux.Router approach, since its specifically defined, just want to be sure that these are correctly working now. |
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.
Two non-blockin comments: #923 (comment)
Great work @srkgupta 👍 |
@srkgupta I have a strange issue where I don't see any change in behavior. When I upload the build and try again I still see the 404 when I click the link to the I have made sure I have your commits. Any thoughts on if maybe something is causing a deployment issue? Can you confirm you see this working on the latest? |
I looked into this in detail and found that the URLs for certain paths started with |
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.
Tested and passed
- Issue discussed above has been resolved
- Did a smoke test covering happy path
- Install works
- Create and attach funtionallity works
- Subscriptions creation and delivery works
LGTM!
Thanks @srkgupta 🎉 If we can get this merged, I can then pull this up into #921 and do a bit more testing on all changes.
Summary
Migrate JIRA codebase to use mux.Router
Ticket Link
https://mattermost.atlassian.net/browse/MM-51188