Software Engineer - Generalist - Located in Munich 🥨 Thank you for visiting this page. If you want to get in touch with me, use one of the ways provided below.
RESTful API の作成に特化したマイクロフレームワーク grape の存在を知ったので調査してみる事にしました。API の実装 に Rails の ActionController は重厚すぎる、Sinatra は軽いけど手間がかかる。。。という中で作られたこのフレームワーク、はたしてその実力は… grape の特徴# grape の特徴は概ね以下の通りです。grape 自体が Rack アプリケーションなので Rails3 に組み込むことが出来ます。というよりは組み込んで使うのが前提のようです(勿論単体でも動きます)。 Rack アプリケーション Sinatra ライクな DSL 自動で JSON にシリアライズ(#serializable_hash または #to_json が存在すればOKみたい) grape を使ってみる# 特徴を掴んだところで、実際にインストールして使って
◆ [Ruby][Sinatra] SinatraでRack::Csrfの例外をハンドリングする SinatraでのCSRF対策にはRack::Csrfが使えますが、普通に use Rack::Csrf, :raise => true とか書いただけでは、errorハンドラで例外を捕捉・処理できません。production環境ではCSRFチェックに引っかかると403応答+真っ白な画面になるのですが、false negativeの可能性が0ではないので、何らかの処理はしておきたいところです。 というわけで、試行錯誤の結果行き着いたのが以下のようなコード。もっと良い方法があったらコメントください。 require 'rubygems' require 'sinatra' require 'rack/csrf' require 'haml' use Rack::Session::Pool use
南関東の「いろんなところから富士山が見える」状況に驚きつづけている 大阪から東京に引っ越して30年以上経つが、じわじわと蓄積されてきた驚きがついに閾値を超えたので筆を執った次第である。正確には「ポメラ DM250を起動してmenuキーを押して新規作成を選んだ」のだが、ポメラを持っていなかったら、さらに驚きが蓄積されていないと…
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く