-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Move api version check to header #2037
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,12 +20,20 @@ func Parse(r *http.Request, root *cmds.Command) (cmds.Request, error) { | |
|
||
stringArgs := make([]string, 0) | ||
|
||
if err := apiVersionMatches(r); err != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the check should not be in the it should be in ipfs specific stuff. if no function called globally for all daemon commands then we should add one that could run before the command is invoked. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would argue that an api version check belongs in the commands lib. Thats a nice feature for the commands library to provide. Being able to have your automatically generated http api do version sanity checks is pretty slick. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Been trying to make sense of this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
agreed there, but then this should be properly done so it does not include There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we could define an API version in the root or something... not sure how this does with command trees and so on. seems like a bigger change than we want this PR to be. (if we want it for this one, then do that PR first and rebase this on that one... but i would say just do the simpler thing now) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Migrated to #2075 |
||
if path[0] != "version" { // compatibility with previous version check | ||
return nil, err | ||
} | ||
} | ||
|
||
cmd, err := root.Get(path[:len(path)-1]) | ||
if err != nil { | ||
// 404 if there is no command at that path | ||
return nil, ErrNotFound | ||
|
||
} else if sub := cmd.Subcommand(path[len(path)-1]); sub == nil { | ||
} | ||
|
||
if sub := cmd.Subcommand(path[len(path)-1]); sub == nil { | ||
if len(path) <= 1 { | ||
return nil, ErrNotFound | ||
} | ||
|
@@ -34,7 +42,6 @@ func Parse(r *http.Request, root *cmds.Command) (cmds.Request, error) { | |
// e.g. /objects/Qabc12345 (we are passing "Qabc12345" to the "objects" command) | ||
stringArgs = append(stringArgs, path[len(path)-1]) | ||
path = path[:len(path)-1] | ||
|
||
} else { | ||
cmd = sub | ||
} | ||
|
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.
and why nil, instead ofnevermindfunc () {}
?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.
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.
ok sounds good