-
Notifications
You must be signed in to change notification settings - Fork 42
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
http: configurable allowed request methods for the API. #190
Conversation
I need to fix tests... tomorrow... |
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.
I don't think we can do this here because we still want to support GET for read-only requests on the read-only API. Let's do this in go-ipfs itself.
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.
I don't think we can do this here because we still want to support GET for read-only requests on the read-only API. Let's do this in go-ipfs itself.
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.
I don't think we can do this here because we still want to support GET for read-only requests on the read-only API. Let's do this in go-ipfs itself.
I am going to argue against this. This causes ambiguity between two APIs which are the same. Tools written to work on the gateway endpoint may not work on the API endpoint even though they are supposed to be using the same API. More importantly, it does not fully fix our current problem. The fact that this is a Read-Only API does not mean that I wish to give anyone capabilities to, for example, Reconsider please? |
After sleeping, I realize that this runs on the gateway endpoint anyway so it should not matter as that is effectively cat'ing too. Still we have seen people complain that it is not obvious that a read-only API is running side-by-side to the gateway, and thus may lead to situations where people forget to secure these paths like they would secure /ipns /ipfs when putting behind nginx etc. The other issues still stand I think... at least in some setups. |
We really need to:
|
Discussed async: make make this an option. |
// For very small slices as these, this should be faster than | ||
// a map lookup. |
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.
Someone did the numbers https://boltandnuts.wordpress.com/2017/11/20/go-slice-vs-maps/
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.
Be careful. Go is constantly changing.
But this isn't performance critical anyways.
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.
Result on go 1.13 mapping string -> bool:
- 1 item - array is faster.
- 2 items - same time.
- 3 items - map is faster.
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.
wow
For anyone following along, I misread: it's |
// For very small slices as these, this should be faster than | ||
// a map lookup. |
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.
Be careful. Go is constantly changing.
But this isn't performance critical anyways.
Bah let me add a test |
This Handler option is used it to allow/deny request by their method. The API is an RPC API so it normally should only work with PUT, but we also use a read-only, GET-based partial API that runs with the gateway. This commit makes the actual allowed (or handled) methods configurable. A test is added, and test facilities improved to be able to set/modify this option.
I have squashed and improved the commit msg. |
@Stebalien technically you should review new changes to |
Effectively enforce that the IPFS API is an RPC API that only handles POST requests.