{"id":224,"date":"2015-12-04T08:00:55","date_gmt":"2015-12-03T23:00:55","guid":{"rendered":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2015\/12\/04\/how-to-make-rack-middleware"},"modified":"2022-10-26T10:07:23","modified_gmt":"2022-10-26T01:07:23","slug":"how-to-make-rack-middleware","status":"publish","type":"post","link":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2015\/12\/04\/how-to-make-rack-middleware\/","title":{"rendered":"10\u5206\u3067\u308f\u304b\u308b Rack \u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u306e\u4f5c\u308a\u65b9"},"content":{"rendered":"

\u5148\u9031\u304b\u3089\u4eca\u65e5\u307e\u30672\u9031\u9593\u30a2\u30e1\u30ea\u30ab\u65c5\u884c\u3092\u3057\u3066\u3044\u305f\u4f0a\u85e4\u3067\u3059\u3002
\n\u30b5\u30f3\u30d5\u30e9\u30f3\u30b7\u30b9\u30b3\u3067\u65e5\u672c\u6642\u9593\u306e\u30c1\u30fc\u30e0\u3068\u30ea\u30e2\u30fc\u30c8\u30ef\u30fc\u30af\u3092\u3057\u3066\u307f\u305f\u611f\u60f3\u306f\u5225\u306e\u8a18\u4e8b\u3067\u66f8\u3053\u3046\u3068\u601d\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n

Rack::ErrorToSlack<\/h2>\n

\u5148\u65e5 hitode909<\/a> \u3055\u3093\u306e \u30ed\u30fc\u30ab\u30eb\u30b5\u30fc\u30d0\u30fc\u3067\u30a8\u30e9\u30fc\u304c\u51fa\u305f\u3089\u5373\u5ea7\u306bSlack\u306b\u6295\u7a3f\u3059\u308bPlack\u30df\u30c9\u30eb\u30a6\u30a7\u30a2<\/a> \u3068\u3044\u3046\u8a18\u4e8b\u3092\u62dd\u898b\u3057\u305f\u306e\u3067\u3059\u304c\u3001\u3061\u3087\u3046\u3069\u305d\u306e\u6642\u306b\u793e\u5185\u3067\u3082\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u30a8\u30f3\u30b8\u30cb\u30a2\u3068\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u30a8\u30f3\u30b8\u30cb\u30a2\u304c\u5bc6\u306a\u95a2\u4fc2\u3067\u958b\u767a\u3092\u9032\u3081\u3066\u3044\u305f\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u304c\u3042\u308a\u3001\u3053\u308c\u306f\u4fbf\u5229\u305d\u3046\u3060\u306d\uff01\u3068\u8a71\u984c\u306b\u4e0a\u308a\u307e\u3057\u305f\u3002
\n\u3068\u3044\u3046\u3053\u3068\u3067\u65e9\u901f Rails \u3067\u305d\u308c\u3068\u540c\u3058\u3088\u3046\u306a\u52d5\u4f5c\u3092\u3059\u308b Rack \u30df\u30c9\u30eb\u30a6\u30a7\u30a2
rack-error_to_slack<\/a> \u3092\u66f8\u3044\u3066\u307f\u307e\u3057\u305f\u3002\u6065\u305a\u304b\u3057\u3044\u3053\u3068\u306b\u4eca\u307e\u3067 Rack \u304c\u305d\u3082\u305d\u3082\u4f55\u306a\u306e\u304b\u3088\u304f\u308f\u304b\u3063\u3066\u3044\u307e\u305b\u3093\u3067\u3057\u305f\u304c\u3001\u5148\u4eba\u305f\u3061\u304c\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u4e0a\u306b\u77e5\u898b\u3092\u6b8b\u3057\u3066\u304a\u3044\u3066\u304f\u308c\u305f\u304a\u304b\u3052\u3067\u534a\u65e5\u3050\u3089\u3044\u3067\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u3002\u4eca\u56de\u306f\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u3092\u3059\u308b Rack \u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u306e\u4f5c\u6210\u65b9\u6cd5\u3092\u307e\u3068\u3081\u3066\u307f\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n

(2\u5206\u7d4c\u904e)<\/p>\n

Rack \u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u306e\u57fa\u672c<\/h2>\n

Rack \u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u3068\u306f\u4f55\u304b\u306b\u3064\u3044\u3066\u306f Ruby Freaks Lounge:\u7b2c25\u56de Rack\u3068\u306f\u4f55\u304b(3)\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u306e\u3059\u3059\u3081<\/a> \u3067\u4e01\u5be7\u306b\u8aac\u660e\u304c\u3055\u308c\u3066\u3044\u308b\u305f\u3081\u3001\u3053\u3061\u3089\u304c\u30aa\u30b9\u30b9\u30e1\u3067\u3059\u3002<\/p>\n

\n

\u3053\u306e\u8a18\u4e8b\u3092\u8aad\u3080\u306e\u306b\u5fc5\u8981\u306a\u6642\u9593\uff1a\u304a\u3088\u305d 3 \u5206<\/p>\n<\/blockquote>\n

\u3068\u66f8\u304b\u308c\u3066\u3044\u308b\u306e\u3067\u30013\u5206\u3067\u8aad\u307f\u7d42\u308f\u3063\u3066\u304f\u3060\u3055\u3044\uff01<\/p>\n

\u4e0a\u306e\u8a18\u4e8b\u306b\u3082\u7c21\u5358\u306b\u66f8\u304b\u308c\u3066\u3044\u307e\u3057\u305f\u304c\u3001Rack \u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u306e\u30df\u30cb\u30de\u30e0\u306a\u5f62\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n

class Foo\n  def initialize(app)\n    @app = app\n  end\n\n  def call(env)\n    res = @app.call(env)\n    # do something\n    res\n  end\nend<\/code><\/pre>\n

\u3053\u306e\u5f62\u3092\u5143\u306b\u3001\u3042\u3068\u306f\u81ea\u5206\u306e\u3084\u308a\u305f\u3044\u3088\u3046\u306a\u51e6\u7406\u3092\u52a0\u3048\u308b\u3060\u3051\u306a\u306e\u3067\u3001\u7c21\u5358\u3067\u3059\u306d\uff01
\n#do something<\/code> \u90e8\u5206\u306e\u5177\u4f53\u4f8b\u3092\u77e5\u308a\u305f\u3044\u65b9\u306f\u3001\u4ee5\u4e0b\u306e\u8a18\u4e8b\u306b\u7c21\u5358\u306a\u4f8b\u304c\u3042\u308a\u307e\u3057\u305f\u306e\u3067\u53c2\u8003\u306b\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n