{"id":430,"date":"2018-01-18T13:22:41","date_gmt":"2018-01-18T04:22:41","guid":{"rendered":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2018\/01\/18\/api_blueprint_dredd"},"modified":"2022-10-28T22:37:53","modified_gmt":"2022-10-28T13:37:53","slug":"api_blueprint_dredd","status":"publish","type":"post","link":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2018\/01\/18\/api_blueprint_dredd\/","title":{"rendered":"API Blueprint\u3067\u66f8\u3044\u305fAPI\u4ed5\u69d8\u66f8\u3092Dredd\u3092\u4f7f\u3063\u3066CircleCI\u3067\u30c6\u30b9\u30c8\u3057\u3066\u307f\u305f"},"content":{"rendered":"
\u4eca\u56de\u3001\u3042\u308b\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067 API Blueprint<\/a> \u3092\u4f7f\u3063\u3066\u3001API\u4ed5\u69d8\u66f8\u3092\u66f8\u304f\u3053\u3068\u306b\u306a\u3063\u305f\u306e\u3067\u3001 \u307e\u305a\u306f \u5225\u306e\u30b3\u30f3\u30bd\u30fc\u30eb\u304b\u3089\u3001 \u751f\u6210\u3055\u308c\u305f \u5bfe\u8a71\u306e\u6700\u5f8c\u306b\u6307\u793a\u304c\u51fa\u3066\u304a\u308a\u3001\u305d\u306e\u6307\u793a\u306b\u5f93\u3063\u3066\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3002<\/p>\n \u3092\u5b9f\u884c\u3057\u3066\u3001 \u6b63\u5e38\u306b\u30c6\u30b9\u30c8\u304c\u901a\u3063\u305f\u3002 \u30c6\u30b9\u30c8\u3092\u518d\u5ea6\u5b9f\u884c\u3057\u3066\u307f\u308b\u3068\u2026\u2026<\/p>\n \u3061\u3083\u3093\u3068 \u3061\u306a\u307f\u306b\u3001\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u4f5c\u6210\u6642\u306b\u3001 URL\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u307f\u308b\u3068\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306a\u753b\u9762\u3068\u306a\u308a\u3001\u30c6\u30b9\u30c8\u306e\u7d50\u679c\u304c\u78ba\u8a8d\u3067\u304d\u308b\u3002 <\/p>\n \u3042\u308b\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u524d\u306b\u3001\u30c6\u30b9\u30c8\u7528\u306e\u30c0\u30df\u30fc\u30c7\u30fc\u30bf\u3092\u4f5c\u6210\u3059\u308b\u3068\u304b\u3001\u524d\u306e\u30c6\u30b9\u30c8\u3067\u4f5c\u3089\u308c\u305f\u30c7\u30fc\u30bf\u3092\u6b21\u306e\u30c6\u30b9\u30c8\u5b9f\u884c\u524d\u306b\u524a\u9664\u3057\u305f\u3044\u5834\u5408\u306a\u3069\u306b\u306f\u3001 \u3068\u306a\u3063\u3066\u3044\u308b\u3002<\/p>\n \u3010\u53c2\u8003URL\u3011 \u3010\u53c2\u8003URL\u3011 \u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306e\u4f8b\u3092\u53c2\u8003\u306b\u3001\u307b\u307c\u305d\u306e\u307e\u307e\u3067\u306f\u3042\u308b\u304c \u4f5c\u6210\u3057\u305f\u4e0a\u3067\u3001 \u3068\u306a\u3063\u3066\u3044\u305f\u7b87\u6240\u3092\u4e0b\u8a18\u306e\u3088\u3046\u306b\u5909\u66f4\u3059\u308b\u3002<\/p>\n \u518d\u5ea6\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3057\u3066\u307f\u308b\u3068\u3001<\/p>\n \u4ee5\u4e0b\u306e \u3010\u53c2\u8003URL\u3011 \u3053\u308c\u3092\u3001 \u3061\u3083\u3093\u3068\u30c6\u30b9\u30c8\u304c\u901a\u3063\u3066\u3044\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u305f\u3002<\/p>\n <\/p>\n \u30ad\u30e3\u30c3\u30b7\u30e5\u304c\u52b9\u3044\u3066\u3044\u308c\u3070\u3001\u4eca\u56de\u306e\u7c21\u5358\u306a\u30c6\u30b9\u30c8\u306735\u79d2\u3050\u3089\u3044\u3067\u7d42\u308f\u3063\u305f\u3002<\/p>\n API\u4ed5\u69d8\u66f8\u306e\u7ba1\u7406\u306e\u8ab2\u984c\u3068\u3057\u3066\u3001<\/p>\n \u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u8d77\u7968\u8005\u306e\u30df\u30b9\u3084\u3001\u5909\u66f4\u4ed5\u69d8\u306e\u53cd\u6620\u6f0f\u308c\u306a\u3069\u306b\u3088\u308a\u3001\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u4ed5\u69d8\u3068\u5b9f\u969b\u306eAPI\u304c\u4e56\u96e2\u3057\u3066\u3057\u307e\u3044\u3001\u4f7f\u3048\u306a\u3044\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u5316\u3057\u3066\u3057\u307e\u3046<\/strong><\/p>\n \u3068\u3044\u3046\u3053\u3068\u304c\u5f80\u3005\u306b\u3057\u3066\u3042\u308b\u3053\u3068\u3060\u3068\u601d\u3046\u304c\u3001 \u4eca\u56de\u306e\u5404\u7a2e\u30d5\u30a1\u30a4\u30eb\u306f\u4e0b\u8a18\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u7f6e\u3044\u3066\u3042\u308b\u3002 \u516c\u5f0f\u30da\u30fc\u30b8 \u3053\u3093\u306a\u306b\u4f7f\u3048\u308b\uff01\u4eca\u3069\u304d\u306eAPI\u30c9\u30ad\u30e5\u30e1\u30f3\u30c6\u30fc\u30b7\u30e7\u30f3\u30c4\u30fc\u30eb<\/a> \u4eca\u56de\u3001\u3042\u308b\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067 API Blueprint \u3092\u4f7f\u3063\u3066\u3001API\u4ed5\u69d8\u66f8\u3092\u66f8\u304f\u3053\u3068\u306b\u306a\u3063\u305f\u306e\u3067\u3001 API Blueprint \u306b\u3064\u3044\u3066\u8abf\u3079\u3066\u3044\u305f\u306e\u3060\u304c\u3001 Dredd \u3068\u3044\u3046API\u306e\u30c6\u30b9\u30c8\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u304c\u4fbf\u5229\u305d\u3046\u3060\u3063\u305f\u306e\u3067\u3001 CircleCI \u3067\u7c21\u5358\u306a\u30c6\u30b9\u30c8\u3059\u308b\u3068\u3053\u308d\u307e\u3067\u89e6\u3063\u3066\u307f\u305f\u3002 Dredd \u306f\u3001 apiary.io \u304c\u63d0\u4f9b\u3057\u3066\u3044\u308bAPI\u306e\u30c6\u30b9\u30c8\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3067\u3001 API Blueprint […]<\/p>\n","protected":false},"author":3,"featured_media":684,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[9],"tags":[399],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts\/430"}],"collection":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/comments?post=430"}],"version-history":[{"count":1,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts\/430\/revisions"}],"predecessor-version":[{"id":3294,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts\/430\/revisions\/3294"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/media?parent=430"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/categories?post=430"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/tags?post=430"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}API Blueprint<\/code> \u306b\u3064\u3044\u3066\u8abf\u3079\u3066\u3044\u305f\u306e\u3060\u304c\u3001 Dredd<\/a> \u3068\u3044\u3046API\u306e\u30c6\u30b9\u30c8\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u304c\u4fbf\u5229\u305d\u3046\u3060\u3063\u305f\u306e\u3067\u3001
CircleCI<\/code> \u3067\u7c21\u5358\u306a\u30c6\u30b9\u30c8\u3059\u308b\u3068\u3053\u308d\u307e\u3067\u89e6\u3063\u3066\u307f\u305f\u3002<\/p>\n
Dredd<\/code> \u306f\u3001
apiary.io<\/code> \u304c\u63d0\u4f9b\u3057\u3066\u3044\u308bAPI\u306e\u30c6\u30b9\u30c8\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3067\u3001
API Blueprint<\/code> \u3060\u3051\u3067\u306f\u306a\u304f\u3001 Swagger<\/a> \u306b\u3082\u5bfe\u5fdc\u3057\u3066\u3044\u308b\u3002<\/p>\n
\u8a66\u3057\u3066\u307f\u305f<\/h2>\n
API\u4f5c\u6210<\/h3>\n
Golang<\/code> \u3067\u975e\u5e38\u306b\u7c21\u5358\u306a
API<\/code> \u3092\u4f5c\u6210\u3002
\n\/message<\/code> \u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u3001
Hello World!!<\/code> \u304c\u8fd4\u308b\u3060\u3051\u3002<\/p>\n
package main\n\nimport (\n "fmt"\n "net\/http"\n "os"\n)\n\nfunc main() {\n http.HandleFunc("\/message", index)\n\n p := port()\n fmt.Println("Listening on Port", p)\n http.ListenAndServe(p, nil)\n}\n\nfunc port() string {\n port := os.Getenv("PORT")\n if len(port) == 0 {\n port = "8080"\n }\n return ":" + port\n}\n\nfunc index(w http.ResponseWriter, r *http.Request) {\n w.WriteHeader(http.StatusOK)\n fmt.Fprintln(w, "Hello World!!")\n}<\/code><\/pre>\n
go build<\/code> \u3092\u3057\u3066\u3001\u30b5\u30fc\u30d0\u30fc\u3092\u8d77\u52d5\u3002<\/p>\n
$ .\/simple-go-server\nListening on Port :8080<\/code><\/pre>\n
curl<\/code> \u3092\u5b9f\u884c\u3057\u3066\u3061\u3083\u3093\u3068\u30ec\u30b9\u30dd\u30f3\u30b9\u304c\u8fd4\u3063\u3066\u304f\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3059\u308b\u3002<\/p>\n
$ curl localhost:8080\/message\nHello World!!<\/code><\/pre>\n
API Blueprint \u3067\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u4f5c\u6210<\/h3>\n
API Blueprint<\/code> \u5f62\u5f0f\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8
doc.apib<\/code> \u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n
FORMAT: 1A\n\n# GET \/message\n+ Response 200 (text\/plain; charset=utf-8)\n\n Hello World!!<\/code><\/pre>\n
Dredd \u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n
Node.js<\/code> \u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u6e08\u307f\u306e\u74b0\u5883\u3067\u3001\u4e0b\u8a18\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066
Dredd<\/code> \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3002<\/p>\n
$ npm install -g dredd\n$ dredd --version<\/code><\/pre>\n
Dredd \u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u4f5c\u6210<\/h3>\n
dredd init<\/code> \u3092\u5b9f\u884c\u3059\u308b\u3053\u3068\u3067\u5bfe\u8a71\u5f62\u5f0f\u3067\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb
dredd.yml<\/code> \u304c\u4f5c\u6210\u3067\u304d\u308b\u3002<\/p>\n
$ dredd init\n? Location of the API description document doc.apib\n? Command to start API backend server e.g. (bundle exec rails server) .\/simple-go-server\n? URL of tested API endpoint localhost:8080\n? Programming language of hooks go\n? Do you want to use Apiary test inspector? No\n? Dredd is best served with Continuous Integration. Create CircleCI config for Dredd? No\n\nConfiguration saved to dredd.yml\n\nInstall hooks handler and run Dredd test with:\n\n $ go get github.com\/snikch\/goodman\/cmd\/goodman\n $ dredd<\/code><\/pre>\n
\n
doc.apib<\/code> \u3092\u5165\u529b<\/li>\n
.\/simple-go-server<\/code> \u3092\u5165\u529b<\/li>\n
localhost:8080<\/code> \u3092\u5165\u529b<\/li>\n
go<\/code> \u3092\u4e0b\u8a18\u306e\u3088\u3046\u306b\u51fa\u3066\u304f\u308b\u9078\u629e\u80a2\u3088\u308a\u9078\u629e<\/li>\n<\/ul>\n
? Programming language of hooks\n ruby\n python\n nodejs\n php\n perl\n\u276f go\n rust<\/code><\/pre>\n
\n
Apiary test inspector<\/code> \u3092\u5229\u7528\u3059\u308b\u304b<\/li>\n
n<\/code> \u3092\u5165\u529b<\/li>\n
CircleCI<\/code> \u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3059\u308b\u304b<\/li>\n
CircleCI 2.0<\/code> \u306b\u306f\u5bfe\u5fdc\u3057\u3066\u304a\u3089\u305a\u3001
1.0<\/code> \u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb
circle.yml<\/code> \u304c\u4f5c\u3089\u308c\u308b\u305f\u3081\u3001
n<\/code> \u3092\u9078\u629e<\/li>\n<\/ul>\n
dredd.yml<\/code> \u306e\u8a2d\u5b9a\u5185\u5bb9\u306f\u3053\u3093\u306a\u611f\u3058\u306b\u306a\u3063\u3066\u3044\u308b\u3002<\/p>\n
dry-run: null\nhookfiles: null\nlanguage: go\nsandbox: false\nserver: .\/simple-go-server\nserver-wait: 3\ninit: false\ncustom: {}\nnames: false\nonly: []\nreporter: []\noutput: []\nheader: []\nsorted: false\nuser: null\ninline-errors: false\ndetails: false\nmethod: []\ncolor: true\nlevel: info\ntimestamp: false\nsilent: false\npath: []\nhooks-worker-timeout: 5000\nhooks-worker-connect-timeout: 1500\nhooks-worker-connect-retry: 500\nhooks-worker-after-connect-wait: 100\nhooks-worker-term-timeout: 5000\nhooks-worker-term-retry: 500\nhooks-worker-handler-host: 127.0.0.1\nhooks-worker-handler-port: 61321\nconfig: .\/dredd.yml\nblueprint: doc.apib\nendpoint: 'localhost:8080'<\/code><\/pre>\n
Dredd \u5b9f\u884c<\/h3>\n
$ go get github.com\/snikch\/goodman\/cmd\/goodman<\/code><\/pre>\n
github.com\/snikch\/goodman\/cmd\/goodman<\/code> \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u5f8c\u306b\u3001
dredd<\/code> \u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3002
\n\u3059\u308b\u3068\u3001\u5148\u307b\u3069\u4f5c\u6210\u3057\u305f\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb .\/dredd.yml<\/code> \u3092\u898b\u3064\u3051\u3066\u3001\u305d\u306e\u8a2d\u5b9a\u306b\u5f93\u3063\u3066\u3001API\u30b5\u30fc\u30d0\u30fc\u3092\u8d77\u52d5\u3002
\n\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u306b\u5bfe\u3057\u3066\u30a2\u30af\u30bb\u30b9\u3092\u3057\u3066\u3001\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u901a\u308a\u306e\u671f\u5f85\u3057\u305f\u30ec\u30b9\u30dd\u30f3\u30b9\u304c\u8fd4\u3063\u3066\u304f\u308b\u304b\u306e\u30c6\u30b9\u30c8\u3092\u884c\u3063\u3066\u304f\u308c\u308b\u3002<\/p>\n$ dredd\ninfo: Configuration '.\/dredd.yml' found, ignoring other arguments.\ninfo: Starting backend server process with command: .\/simple-go-server\ninfo: Waiting 3 seconds for backend server process to start\nListening on Port :8080\ninfo: Beginning Dredd testing...\npass: GET (200) \/message duration: 29ms\ncomplete: 1 passing, 0 failing, 0 errors, 0 skipped, 1 total\ncomplete: Tests took 34ms\ninfo: Backend server process exited<\/code><\/pre>\n
\n\u3061\u306a\u307f\u306b\u3001 doc.apib<\/code> \u3092\u4e0b\u8a18\u306e\u3088\u3046\u306b\u3001
Hello<\/code> \u3092
Good Morning<\/code> \u306b\u4fee\u6b63\u3057\u3066\u3001<\/p>\n
FORMAT: 1A\n\n# GET \/message\n+ Response 200 (text\/plain; charset=utf-8)\n\n Good Morning World!!<\/code><\/pre>\n
$ dredd\ninfo: Configuration '.\/dredd.yml' found, ignoring other arguments.\ninfo: Starting backend server process with command: .\/simple-go-server\ninfo: Waiting 3 seconds for backend server process to start\nListening on Port :8080\ninfo: Beginning Dredd testing...\nfail: GET (200) \/message duration: 30ms\ninfo: Displaying failed tests...\nfail: GET (200) \/message duration: 30ms\nfail: body: Real and expected data does not match.\n\nrequest:\nmethod: GET\nuri: \/message\nheaders:\n User-Agent: Dredd\/4.9.2 (Darwin 17.3.0; x64)\n Content-Length: 0\n\nbody:\n\n\n\nexpected:\nheaders:\n Content-Type: text\/plain; charset=utf-8\n\nbody:\nGood Morning World!!\n\nstatusCode: 200\n\n\nactual:\nstatusCode: 200\nheaders:\n date: Tue, 16 Jan 2018 08:22:59 GMT\n content-length: 14\n content-type: text\/plain; charset=utf-8\n connection: close\n\nbody:\nHello World!!\n\n\n\n\ncomplete: 0 passing, 1 failing, 0 errors, 0 skipped, 1 total\ncomplete: Tests took 34ms\ninfo: Backend server process exited<\/code><\/pre>\n
fail: body: Real and expected data does not match.<\/code> \u3068\u8868\u793a\u3055\u308c\u3066\u3044\u3066\u3001
body<\/code> \u304c\u4e00\u81f4\u3057\u3066\u3044\u306a\u3044\u3063\u3066\u3044\u3046\u5185\u5bb9\u3067
Fail<\/code> \u3057\u305f\u3002
\n\u256d( \uff65\u3142\uff65)\u0648 \u0311\u0311 \uff78\uff9e\uff6f !<\/p>\nApiary test inspector<\/h3>\n
Apiary test inspector<\/code> \u3092\u5229\u7528\u3059\u308b\u8a2d\u5b9a\u306b\u3059\u308b\u3068\u3001
Apiary API key<\/code> \u3092\u805e\u304b\u308c\u308b\u3002
\n\u4f55\u3082\u5165\u529b\u305b\u305a\u306b\u30a8\u30f3\u30bf\u30fc\u30ad\u30fc\u3092\u62bc\u3059\u3068\u3001\u30c6\u30b9\u30c8\u7d50\u679c\u304c https:\/\/app.apiary.io<\/code> \u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3055\u308c\u3001\u30d1\u30d6\u30ea\u30c3\u30af\u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u3001WEB\u4e0a\u3067\u78ba\u8a8d\u3067\u304d\u308b\u3002
\n\u30c6\u30b9\u30c8\u5b9f\u884c\u3057\u305f\u6700\u5f8c\u306b\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306bURL\u304c\u8868\u793a\u3055\u308c\u3066\u3001<\/p>\ncomplete: See results in Apiary at: https:\/\/app.apiary.io\/public\/tests\/run\/eb7093e0-565e-45e4-82f1-de14fda0cf72<\/code><\/pre>\n
\n\u30c6\u30b9\u30c8\u7d50\u679c\u306f\u300124\u6642\u9593\u4fdd\u6301\u3055\u308c\u308b\u3002<\/p>\nHook \u306b\u3064\u3044\u3066<\/h3>\n
Hook<\/code> \u3092\u5229\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3002
\ndredd init<\/code> \u3092\u5b9f\u884c\u3057\u305f\u969b\u306b\u3001\u9078\u629e\u80a2\u3068\u3057\u3066\u8868\u793a\u3055\u308c\u305f\u3088\u3046\u306b\u3001
Hook<\/code> \u3067\u4f7f\u7528\u3067\u304d\u308b\u8a00\u8a9e\u306f\u3001<\/p>\n
\n
\nHook Scripts \u2014 Languages<\/a><\/p>\nHook<\/code> \u3067\u5229\u7528\u3067\u304d\u308b\u7a2e\u985e\u306f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u53c2\u8003\u306b\u3057\u3066\u3044\u305f\u3060\u304d\u305f\u3044\u304c\u3001\u4e0b\u8a18\u306e\u7a2e\u985e\u3092\u6307\u5b9a\u3067\u304d\u308b\u3002<\/p>\n
\n
\nHook Scripts \u2014 Types of Hooks<\/a><\/p>\nHook \u4f5c\u6210<\/h3>\n
test\/hooks.go<\/code> \u3068\u3057\u3066\u4e0b\u8a18\u306e\u3088\u3046\u306a
Hook<\/code> \u3092\u4f5c\u6210\u3057\u305f\u3002
\n\/message<\/code> \u3078\u30a2\u30af\u30bb\u30b9\u3059\u308b\u524d\u306b\u3001\u30b3\u30f3\u30bd\u30fc\u30eb\u4e0a\u306b\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8868\u793a\u3059\u308b\u3060\u3051\u2026\u2026\u3002<\/p>\n
package main\n\nimport (\n "fmt"\n\n "github.com\/snikch\/goodman\/hooks"\n trans "github.com\/snikch\/goodman\/transaction"\n)\n\nfunc main() {\n h := hooks.NewHooks()\n server := hooks.NewServer(hooks.NewHooksRunner(h))\n h.Before("\/message > GET", func(t *trans.Transaction) {\n fmt.Println("-------------------")\n fmt.Println("before modification")\n fmt.Println("-------------------")\n })\n server.Serve()\n defer server.Listener.Close()\n}<\/code><\/pre>\n
go build<\/code> \u3092\u884c\u3046\u3002<\/p>\n
$ go build -o hooks test\/hooks.go<\/code><\/pre>\n
hooks<\/code> \u30d5\u30a1\u30a4\u30eb\u304c\u3067\u304d\u308b\u306e\u3067\u3001
dredd.yml<\/code> \u3067\u3001<\/p>\n
hookfiles: null<\/code><\/pre>\n
hookfiles: hooks<\/code><\/pre>\n
$ dredd\ninfo: Configuration '.\/dredd.yml' found, ignoring other arguments.\ninfo: Starting backend server process with command: .\/simple-go-server\ninfo: Waiting 3 seconds for backend server process to start\nListening on Port :8080\ninfo: Beginning Dredd testing...\ninfo: Found Hookfiles: 0=\/Users\/eugenesasa\/work\/src\/github.com\/mmmsasaki\/simple-go-server\/hooks\ninfo: Spawning 'go' hooks handler process.\ninfo: Hooks handler stdout: Sending to channel\n\nCompleted\n\ninfo: Hooks handler stderr: 2018\/01\/18 07:42:27 Starting hooks server\n\ninfo: Hooks handler stdout: Starting\n\ninfo: Hooks handler stdout: Accepting connection\n\ninfo: Successfully connected to hooks handler. Waiting 0.1s to start testing.\ninfo: Hooks handler stdout: -------------------\nbefore modification\n-------------------\n\npass: GET (200) \/message duration: 53ms\ninfo: Hooks handler stderr: 2018\/01\/18 07:42:28 Shutting down hooks servers\n\ncomplete: 1 passing, 0 failing, 0 errors, 0 skipped, 1 total\ncomplete: Tests took 5653ms\ninfo: Backend server process exited<\/code><\/pre>\n
\/message<\/code> \u3078\u30a2\u30af\u30bb\u30b9\u3059\u308b\u524d\u306b\u3001\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u3066\u304a\u308a\u3001
hooks<\/code> \u304c\u5b9f\u884c\u3055\u308c\u3066\u3044\u308b\u306e\u304c\u898b\u3048\u308b\u304b\u3068\u601d\u3046\u3002<\/p>\n
info: Hooks handler stdout: -------------------\nbefore modification\n-------------------<\/code><\/pre>\n
Express.js<\/code> \u306e\u30b5\u30f3\u30d7\u30eb\u3067\u306f\u3001\u30c7\u30fc\u30bf\u306e\u30d5\u30a3\u30af\u30b9\u30c1\u30e3\u3092\u8aad\u307f\u8fbc\u3093\u3060\u308a\u3057\u3066\u3044\u308b\u306e\u3067\u3001\u3053\u3061\u3089\u3082\u53c2\u8003\u306b\u3002<\/p>\n
\ndredd-example\/hooks.js<\/a><\/p>\nCircleCI<\/h3>\n
CircleCI<\/code> \u3067\u3082\u5b9f\u884c\u3059\u308b\u3053\u3068\u3067\u3001\u7d99\u7d9a\u7684\u306b\u5b9f\u88c5\u3057\u305f\u6a5f\u80fd\u3068\u3001\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306e\u4e56\u96e2\u304c\u306a\u3044\u304b\u3068\u3044\u3046\u3053\u3068\u304c\u30c1\u30a7\u30c3\u30af\u3067\u304d\u308b\u3002
\n.circleci\/config.yml<\/code> \u306f\u4e0b\u8a18\u306e\u3088\u3046\u306b\u3057\u305f\u3002<\/p>\n
version: 2\njobs:\n build:\n docker:\n - image: circleci\/golang:latest\n working_directory: \/go\/src\/github.com\/mmmsasaki\/simple-go-server\n steps:\n - checkout\n - run: curl -sL https:\/\/deb.nodesource.com\/setup_8.x | sudo -E bash -\n - run: sudo apt-get install -y nodejs\n - run: go version\n - run: node --version\n - run: npm --version\n - restore_cache:\n name: restore node_modules cache\n key: dredd\n - run:\n name: npm install dredd\n command: npm install dredd\n - save_cache:\n name: save node_modules cache\n key: dredd\n paths:\n - node_modules\n - run: go build\n - run: go get github.com\/snikch\/goodman\/cmd\/goodman\n - run: go build -o hooks .\/test\/hooks.go\n - run: .\/node_modules\/dredd\/bin\/dredd<\/code><\/pre>\n
\u307e\u3068\u3081<\/h2>\n
API Blueprint<\/code> \u3068
Dredd<\/code> \u3092\u4f7f\u3044\u3001
CircleCI<\/code> \u3067\u3001\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3068API\u306e\u9593\u3067\u4e56\u96e2\u304c\u306a\u3044\u304b\u3001\u3068\u3044\u3046\u30c1\u30a7\u30c3\u30af\u3092\u7d99\u7d9a\u7684\u306b\u884c\u3048\u3070\u3001\u3053\u306e\u554f\u984c\u306f\u89e3\u6c7a\u3067\u304d\u305d\u3046\u306a\u6c17\u3082\u3057\u3066\u3044\u308b\u3002
\n\u307e\u305f\u3001\u5b9f\u969b\u306b\u30b5\u30fc\u30d0\u30fc\u3092\u8d77\u52d5\u3057\u3066\u3001\u30a2\u30af\u30bb\u30b9\u3057\u3066\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u30c6\u30b9\u30c8\u3059\u308b\u306e\u3067\u3001 \u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u3092\u66f8\u304f\u5de5\u6570\u3082\u3082\u3057\u304b\u3057\u305f\u3089\u524a\u6e1b\u3067\u304d\u308b\u304b\u3082\u3057\u308c\u306a\u3044\u306a\u3001\u3068\u5c11\u3057\u671f\u5f85\u3057\u3066\u3044\u308b\u3002<\/p>\n
\nmmmsasaki\/simple-go-server<\/a><\/p>\n\u53c2\u8003<\/h3>\n
\nAPI Blueprint<\/a>
\nDredd \u2014 HTTP API Testing Framework<\/a><\/p>\n
\nAPI Blueprint\u3067\u66f8\u3044\u305fWeb API\u3092dredd\u3067\u30c6\u30b9\u30c8\u3059\u308b - Qiita<\/a>
\nApi\u30c8\u3099\u30ad\u30e5\u30e1\u30f3\u30c6\u30fc\u30b7\u30e7\u30f3\u30c4\u30fc\u30eb\u3092\u4f7f\u3044\u3053\u306a\u3059\u3010api blueprint\u7de8\u3011<\/a>
\nAPI Blueprint \u3067 API \u4ed5\u69d8\u66f8\u3092\u66f8\u3044\u3066\u3001\u914d\u5e03\u7528\u306e HTML \u3092\u81ea\u52d5\u751f\u6210\u3059\u308b\u65b9\u6cd5 | GMO\u30a2\u30c9\u30d1\u30fc\u30c8\u30ca\u30fc\u30ba\u30b0\u30eb\u30fc\u30d7 TECH BLOG byGMO<\/a>
\nAPI Blueprint\u3067Web API\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u751f\u6210\u3059\u308b - Qiita<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"