Giter Site home page Giter Site logo

moonrope's People

Contributors

adamcooke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

moonrope's Issues

why POST /api/v1/monkey/info?

Hi there,

I've started using staytus thanks for that a great app.

I'm a little confused by the non-REST implementation of the api however.
The standards are defined quite well and are very common these days: https://gist.github.com/joyrexus/40d5ac6017be2c71e1ba

Normally one would do a GET /api/v1/monkey/1 to get object :id 1
Forcing users to do a POST to a /info endpoint is very unintuitive?

or am i misreading something?

I spent some time figuring out how the api was hooked into rails as that too is non standard?

Im interested in contributing to this app as its very useful and I'm grateful for it. And I would start at once with re-implementing the api probably using https://github.com/ruby-grape/grape

I'd appreciate your feedback.
Thanks

Problem with handling bad input

We were having a go with atech/postal's API natively in PHP instead of using an existing client library and encountered a minor issue during our testing.

In PHP, converting an empty array (or an array without named keys) to JSON results in square bracket wrapped output [] as opposed to curly braces {} which makes sense.

However sending [] instead of {} to an API powered by Moonrope causes an error here:

value = @params.has_key?(key.to_s) ? @params[key.to_s] : @defaults[key.to_s]

The stack trace is as follows (collapsed for brevity)
[web.1:3047] [2019-07-18T14:42:12.036] INFO -- : Started POST "/api/v1/send/message" for redacted at 2019-07-18 14:42:12 +0100
[web.1:3047] [2019-07-18T14:42:12.041] INFO -- : NoMethodError
[web.1:3047] [2019-07-18T14:42:12.041] INFO -- : undefined method `has_key?' for []:Array
[web.1:3047] [2019-07-18T14:42:12.041] INFO -- : /opt/postal/vendor/bundle/ruby/2.5.0/gems/moonrope-2.0.1/lib/moonrope/param_set.rb:32:in `_value_for'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/moonrope-2.0.1/lib/moonrope/action.rb:242:in `block in validate_parameters'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/moonrope-2.0.1/lib/moonrope/action.rb:229:in `each'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/moonrope-2.0.1/lib/moonrope/action.rb:229:in `validate_parameters'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/moonrope-2.0.1/lib/moonrope/action.rb:160:in `block in execute'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/moonrope-2.0.1/lib/moonrope/action.rb:112:in `convert_errors_to_action_result'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/moonrope-2.0.1/lib/moonrope/action.rb:156:in `execute'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/moonrope-2.0.1/lib/moonrope/request.rb:113:in `execute'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/moonrope-2.0.1/lib/moonrope/rack_middleware.rb:88:in `call'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/moonrope-2.0.1/lib/moonrope/doc_server.rb:118:in `call'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/rack-2.0.6/lib/rack/tempfile_reaper.rb:15:in `call'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/rack-2.0.6/lib/rack/etag.rb:25:in `call'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/rack-2.0.6/lib/rack/conditional_get.rb:38:in `call'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/rack-2.0.6/lib/rack/head.rb:12:in `call'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.2.1/lib/action_dispatch/http/content_security_policy.rb:18:in `call'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/rack-2.0.6/lib/rack/session/abstract/id.rb:232:in `context'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/rack-2.0.6/lib/rack/session/abstract/id.rb:226:in `call'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.2.1/lib/action_dispatch/middleware/cookies.rb:670:in `call'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.2.1/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/callbacks.rb:98:in `run_callbacks'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.2.1/lib/action_dispatch/middleware/callbacks.rb:26:in `call'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.2.1/lib/action_dispatch/middleware/debug_exceptions.rb:61:in `call'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.2.1/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2.1/lib/rails/rack/logger.rb:38:in `call_app'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2.1/lib/rails/rack/logger.rb:28:in `call'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.2.1/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.2.1/lib/action_dispatch/middleware/request_id.rb:27:in `call'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/rack-2.0.6/lib/rack/method_override.rb:22:in `call'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/rack-2.0.6/lib/rack/runtime.rb:22:in `call'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.2.1/lib/action_dispatch/middleware/executor.rb:14:in `call'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.2.1/lib/action_dispatch/middleware/static.rb:127:in `call'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/rack-2.0.6/lib/rack/sendfile.rb:111:in `call'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/secure_headers-6.0.0/lib/secure_headers/middleware.rb:13:in `call'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/sentry-raven-2.7.4/lib/raven/integrations/rack.rb:51:in `call'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2.1/lib/rails/engine.rb:524:in `call'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/puma-3.12.0/lib/puma/commonlogger.rb:38:in `call'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/puma-3.12.0/lib/puma/configuration.rb:225:in `call'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/puma-3.12.0/lib/puma/server.rb:658:in `handle_request'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/puma-3.12.0/lib/puma/server.rb:472:in `process_client'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/puma-3.12.0/lib/puma/server.rb:332:in `block in run'
/opt/postal/vendor/bundle/ruby/2.5.0/gems/puma-3.12.0/lib/puma/thread_pool.rb:133:in `block in spawn_thread'

Obviously while such occurrences should be few and far between, presumably it would be possible for Moonrope to catch any error whilst handling the input at some point and return 400 Bad Request instead of 500 Internal Server Error?

JSON parameter?

How do I accept JSON input as a parameter without an associated name for the input? Is there a means to grab the raw body of the request and parse from there?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.