9
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

SinatraでJSONを受け取る

Posted at
Gemfile
gem "rack-contrib", require: ["rack/contrib/post_body_content_type_parser"], github: "rack/rack-contrib"
config.ru
use Rack::PostBodyContentTypeParser
run YourApplication

これだけ。


Rack::PostBodyContentTypeParserはその名の通りContentTypeを見てbodyをパースするmiddlewareで、実装を見ると実体はapplication/jsonのときはJSON.parse(body)みたいなことをしているだけ。

現在リリースされているバージョンだと正常に動かないので、開発版をgithubから取得している。

9
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?