Repository navigation
Adding parameter feedback - #239
Merged
Dynom merged 4 commits intoJan 20, 2019
Merged
Conversation
Owner
|
Thanks for taking time & care of this. I guess I'm fine with the We should, however, remove Go <= 1.9 Travis CI builds and make it clear in the README that the minimum supported version is Go 1.10. |
h2non
approved these changes
Jan 20, 2019
h2non
left a comment
Owner
There was a problem hiding this comment.
Overall, LGTM. The parsing approach is mor solid and opens the possibility to more fine-grained a validation and error reporting.
h2non
reviewed
Jan 20, 2019
| - env: LIBVIPS=8.3 | ||
| - env: LIBVIPS=master | ||
| - go: 1.8.x | ||
| - go: 1.9.x |
Owner
|
Feel free to merge when ready, bump patch version and publish a new release. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Warning. Here be (albeit tiny) dragons.
I've spent a quite a while trying to simplify the parameter handling. It was rather complicated to grasp since there were two pretty different cases: The Pipeline and the HTTP parameter handling.
I've, eventually, came up with a pretty radical rewrite of the parameter handling. There is quite a bit of boilerplate, but (imho) it's now much simpler to deal with parameters and much less passing around of
interface{}types.There aren't breaking API changes. In some cases it wasn't allowed to pass in a string where a number was expected (e.g.:
{"width": 200}versus{"width": "200"}). In the new situation that is allowed. While I'm not necessarily a fan of allowing strings where numbers are "correct", this is a side-effect of how theparse<T>()functions are implemented. It's more generic (HTTP parameter versus JSON types) and hopefully easier to understand.There is also slightly more information when the user does pass in a wrong parameter, e.g.:
curl -sv "http://localhost:9000/pipeline?url=https://pbs.twimg.com/media/DwX-vRdUYAACZ0x.jpg&operations=%5B%7B%22operation%22%3A%22resize%22%2C%22params%22%3A%7B%22quality%22%3A70%2C%22noprofile%22%3Atrue%2C%22stripmeta%22%3Atrue%2C%22nocrop%22%3A%22foo%22%2C%22width%22%3A865%7D%7D%5D"{ "message": "Error while processing the image: error while processing parameter \"nocrop\" with value \"foo\", error: unsupported value", "code": 1 }Inspired by issues #236 and #233
Breaking Pre-Go1.10 compatibility
I've added the new (since Go 1.10) flag
DisallowUnknownFields()on the JSON decoder. This causes Imaginary to be >= Go 1.10. Personally I think it's fine, but if this is a problem I can drop the flag and this way we'll support older Go versions.