{"id":404,"date":"2019-05-20T10:40:21","date_gmt":"2019-05-20T01:40:21","guid":{"rendered":"http:\/\/localhost:8000\/?p=404"},"modified":"2021-01-23T10:40:53","modified_gmt":"2021-01-23T01:40:53","slug":"ktor-locations","status":"publish","type":"post","link":"http:\/\/localhost:8000\/2019\/05\/ktor-locations.html","title":{"rendered":"Ktor\u3067Locations\u306ePOST\u4f7f\u3046\u969b\u306e\u6ce8\u610f\u70b9"},"content":{"rendered":"

Ktor<\/a> \u3067 Locations<\/a> \u3092\u4f7f\u3046\u969b\u3001\u666e\u901a\u306bForm Data\u3068\u3057\u3066POST\u3059\u308b\u3068404\u30a8\u30e9\u30fc\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u3002
\n
GET parameters\u306e\u9805<\/a> \u3092\u53c2\u7167\u3059\u308b\u3068\u3001\u30b5\u30dd\u30fc\u30c8\u5bfe\u8c61\u306e\u6a5f\u80fd\u306e\u306f\u305a\u306a\u306e\u306b\u3002
\n\u3061\u306a\u307f\u306b\u3001
Issue #601<\/a> \u3082\u3042\u304c\u3063\u3066\u3044\u308b\u304c\u3001\u534a\u5e74\u4ee5\u4e0a\u653e\u7f6e\u3055\u308c\u3066\u3044\u308b\u3002\u81ea\u5206\u3082\u30b3\u30e1\u30f3\u30c8\u3092\u8ffd\u52a0\u3057\u3066\u304a\u3044\u305f\u3002
\n\u3053\u3053\u3067\u306f\u6b8b\u5ff5\u306a\u65b9\u6cd5\u3067\u306f\u3042\u308b\u304c\u3001\u3044\u304f\u3064\u304b\u56de\u907f\u7b56\u304c\u3042\u308b\u306e\u3067\u3001\u305d\u306e\u65b9\u6cd5\u3092\u8a18\u8f09\u3057\u3066\u304a\u304f\u3002<\/p>\n

\u30a8\u30e9\u30fc\u306b\u306a\u308b\u30d1\u30bf\u30fc\u30f3<\/h2>\n

\u3053\u306e\u30b1\u30fc\u30b9\u306e\u3088\u3046\u306b\u3001Form Data\u3068\u3057\u3066\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u53d7\u3051\u53d6\u308d\u3046\u3068\u3059\u308b\u3068\u3001404\u30a8\u30e9\u30fc\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u3002<\/p>\n

@Location("\/hoge")\ndata class HogeParamater(val param1, val param2)\n\nrouting {\n    post<HogeParamater> { param ->\n        \/\/ HogeParamater\u3092\u4f7f\u3063\u305f\u4f55\u3089\u304b\u306e\u51e6\u7406\n    }\n}<\/code><\/pre>\n

\u8a66\u3057\u306b\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u3092\u8a2d\u5b9a\u3059\u308b\u3068\u30a8\u30e9\u30fc\u306b\u306f\u306a\u3089\u306a\u3044\u304c\u3001\u5024\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u306e\u307e\u307e\u3067\u3042\u308b\u3002<\/p>\n

@Location("\/hoge")\ndata class HogeParamater(val param1: String = "default1", val param2: String = "default2")\n\nrouting {\n    post<HogeParamater> { param ->\n        \/\/ HogeParamater\u3092\u4f7f\u3063\u305f\u4f55\u3089\u304b\u306e\u51e6\u7406\n    }\n}<\/code><\/pre>\n

\u56de\u907f\u65b9\u6cd5\uff11<\/h2>\n

\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30d1\u30e9\u30e1\u30fc\u30bf\u306b\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u3092\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u3067404\u30a8\u30e9\u30fc\u3092\u56de\u907f\u3057\u3001var<\/code>\u3067\u5ba3\u8a00\u3059\u308b\u3053\u3068\u3067\u30d1\u30e9\u30e1\u30fc\u30bf\u3078\u306e\u518d\u4ee3\u5165\u3092\u8a31\u53ef\u3057\u305f\u4e0a\u3067receiveParameters<\/code>\u304b\u3089\u5024\u3092\u53d6\u5f97\u3057\u3066\u4e0a\u66f8\u304d\u3059\u308b\u3002
\nURL\u304c\u5909\u308f\u3089\u306a\u3044\u306e\u3067\u3001\u3053\u306e\u65b9\u6cd5\u304c\u307e\u3060\u3057\u3082\u4e00\u756a\u307e\u3057\u304b\u3068\u5224\u65ad\u3057\u3001\u81ea\u5206\u306f\u3053\u306e\u65b9\u6cd5\u3092\u9078\u629e\u3057\u305f\u3002 <\/p>\n

@Location("\/hoge")\ndata class HogeParamater(var param1: String = "default1", var param2: String = "default2")\n\nrouting {\n    post<HogeParamater> { param ->\n        val receiveParameters = call.receiveParameters()\n        param.param1 = receiveParameters["param1"]!!\n        param.param2 = receiveParameters["param2"]!!\n        \/\/ HogeParamater\u3092\u4f7f\u3063\u305f\u4f55\u3089\u304b\u306e\u51e6\u7406\n\n    }\n}<\/code><\/pre>\n

\u56de\u907f\u65b9\u6cd5\uff12<\/h2>\n

URL\u57cb\u3081\u8fbc\u307f\u30d1\u30e9\u30e1\u30fc\u30bf\u306b\u3059\u308b\u3002
\n\u3053\u308c\u3082\u52d5\u304f\u306e\u3060\u304c\u3001URL\u304c\u5909\u308f\u3063\u3066\u3057\u307e\u3046\u306e\u3067\u975e\u5e38\u306b\u60b2\u3057\u3044\u3002<\/p>\n

@Location("\/hoge\/{param1}\/{param2}")\ndata class HogeParamater(val param1, val param2)\n\nrouting {\n    post<HogeParamater> { param ->\n        val receiveParameters = call.receiveParameters()\n        param.param1 = receiveParameters["param1"]!!\n        param.param2 = receiveParameters["param2"]!!\n        \/\/ HogeParamater\u3092\u4f7f\u3063\u305f\u4f55\u3089\u304b\u306e\u51e6\u7406\n\n    }\n}<\/code><\/pre>\n

\u56de\u907f\u65b9\u6cd5\uff13<\/h2>\n

\u305d\u3082\u305d\u3082Locations\u3092\u4f7f\u308f\u305a\u3001Routing\u3092\u5229\u7528\u3059\u308b\u3002
\n\u3053\u306e\u65b9\u6cd5\u3082\u554f\u984c\u306a\u304f\u52d5\u304f\u304c\u3001\u305d\u3082\u305d\u3082\u30d1\u30e9\u30e1\u30fc\u30bf\u3092type safe\u306b\u53d7\u3051\u53d6\u308b\u305f\u3081\u306bLocations\u3092\u5c0e\u5165\u3057\u305f\u306e\u3067\u3042\u308b\u304b\u3089\u3001\u975e\u5e38\u306b\u60b2\u3057\u3044\u3002<\/p>\n

data class HogeParamater(val param1, val param2)\n\nrouting {\n    post("\/hoge") {\n        val receiveParameters = call.receiveParameters()\n        val param1 = receiveParameters["param1"]!!\n        val param2 = receiveParameters["param2"]!!\n        val param = HogeParamater(param1, param2)\n        \/\/ HogeParamater\u3092\u4f7f\u3063\u305f\u4f55\u3089\u304b\u306e\u51e6\u7406\n}<\/code><\/pre>\n

\u6700\u5f8c\u306b<\/h2>\n

\u81ea\u5206\u306e\u77e5\u8b58\u4e0d\u8db3\u306e\u53ef\u80fd\u6027\u3082\u5927\u3044\u306b\u3042\u308b\u304c\u3001Ktor\u306f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u958b\u767a\u306e\u95a2\u5fc3\u4e8b\u306eRouting\u3084Validation\u304c\u307e\u3060\u307e\u3060\u3053\u306a\u308c\u3066\u306a\u3044\u611f\u304c\u5f37\u3044\u3002
\n\u4eca\u56de\u30ec\u30d9\u30eb\u306e\u30d0\u30b0\u304c\u653e\u7f6e\u3055\u308c\u308b\u3088\u3046\u3060\u3068\u3001Star\u306e\u6570\u306f\u591a\u3044\u3082\u306e\u306e\u5b9f\u969b\u4f7f\u3063\u3066\u308b\u4eba\u306f\u5c11\u306a\u3044\u306e\u3067\u306f\uff1f\u3068\u3044\u3046\u6c17\u6301\u3061\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u3002
\n\u4f55\u306b\u3057\u3066\u3082\u500b\u4eba\u30b5\u30fc\u30d3\u30b9\u3068\u304b\u306a\u3089\u3044\u3044\u304b\u3082\u3057\u308c\u306a\u3044\u304c\u3001\u30d7\u30ed\u30c0\u30af\u30b7\u30e7\u30f3\u3067\u4f7f\u3046\u306e\u306f\u3082\u3046\u5c11\u3057\u69d8\u5b50\u898b\u3057\u305f\u3044\u3068\u601d\u3046\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

Ktor \u3067 Locations \u3092\u4f7f\u3046\u969b\u3001\u666e\u901a\u306bForm Data\u3068\u3057\u3066POST\u3059\u308b\u3068404\u30a8\u30e9\u30fc\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u3002 GET parameters\u306e\u9805 \u3092\u53c2\u7167\u3059\u308b\u3068\u3001\u30b5\u30dd\u30fc\u30c8\u5bfe\u8c61\u306e\u6a5f\u80fd\u306e\u306f\u305a\u306a\u306e\u306b\u3002 \u3061\u306a\u307f\u306b\u3001 Issue #601 \u3082\u3042\u304c\u3063\u3066\u3044\u308b\u304c\u3001\u534a\u5e74\u4ee5\u4e0a\u653e\u7f6e\u3055\u308c\u3066\u3044\u308b\u3002\u81ea\u5206\u3082\u30b3\u30e1\u30f3\u30c8\u3092\u8ffd\u52a0\u3057\u3066\u304a\u3044\u305f\u3002 \u3053\u3053\u3067\u306f\u6b8b\u5ff5\u306a\u65b9\u6cd5\u3067\u306f\u3042\u308b\u304c\u3001\u3044\u304f\u3064\u304b\u56de\u907f\u7b56\u304c\u3042\u308b\u306e\u3067\u3001\u305d\u306e\u65b9\u6cd5\u3092\u8a18\u8f09\u3057\u3066\u304a\u304f\u3002 \u30a8\u30e9\u30fc\u306b\u306a\u308b\u30d1\u30bf\u30fc\u30f3 \u3053\u306e\u30b1\u30fc\u30b9\u306e\u3088\u3046\u306b\u3001Form Data\u3068\u3057\u3066\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u53d7\u3051\u53d6\u308d\u3046\u3068\u3059\u308b\u3068\u3001404\u30a8\u30e9\u30fc\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u3002 @Location("\/hoge") data class HogeParamater(val param1, val param2) routing { post<HogeParamater> { param -> \/\/ HogeParam <\/span>Continue Reading<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[27,28],"tags":[],"_links":{"self":[{"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/posts\/404"}],"collection":[{"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/comments?post=404"}],"version-history":[{"count":1,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/posts\/404\/revisions"}],"predecessor-version":[{"id":405,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/posts\/404\/revisions\/405"}],"wp:attachment":[{"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/media?parent=404"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/categories?post=404"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/tags?post=404"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}