{"id":180109,"date":"2020-10-29T08:14:06","date_gmt":"2020-10-29T00:14:06","guid":{"rendered":"http:\/\/4563.org\/?p=180109"},"modified":"2020-10-31T02:30:02","modified_gmt":"2020-10-30T18:30:02","slug":"golang-%e7%9a%84-http-%e5%9b%9e%e8%b0%83%e7%bb%93%e6%9e%9c%e5%a6%82%e4%bd%95%e8%bf%94%e5%9b%9e%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=180109","title":{"rendered":"golang \u7684 http \u56de\u8c03\u7ed3\u679c\u5982\u4f55\u8fd4\u56de\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  golang \u7684 http \u56de\u8c03\u7ed3\u679c\u5982\u4f55\u8fd4\u56de\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : coool <\/span>  <span><i><\/i> 1<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<h3>\u9700\u6c42\uff1a<\/h3>\n<p>\u6211\u4eec\u8981\u8bf7\u6c42\u8baf\u98de\u7684 \/upload http \u63a5\u53e3\u505a\u8bed\u97f3\u8bc6\u522b\uff0c\u8baf\u98de\u8bc6\u522b\u6210\u529f\u540e\u4f1a\u901a\u8fc7 \/callback URL \u901a\u77e5\uff0c\u6211\u4eec\u62ff\u5230\u901a\u77e5\u540e\u518d\u53bb\u8bf7\u6c42\u8baf\u98de\u7684 \/getResult \u63a5\u53e3\u62ff\u5230\u8bed\u97f3\u8bc6\u522b\u7ed3\u679c<\/p>\n<h3>\u95ee\u9898\uff1a<\/h3>\n<ul>\n<li>\n<p>\u540c\u4e8b\u505a\u4e86\u4e00\u6b21\u5c01\u88c5\uff0c\u4ece callback URL \u62ff\u5230\u901a\u77e5\uff0c\u7136\u540e \/getResult \u62ff\u5230\u7ed3\u679c\u540e\u53d1\u8d77 http \u8bf7\u6c42\uff0c\u628a\u8bed\u97f3\u8bc6\u522b\u7ed3\u679c\u653e\u5230 request \u7684 Body \u91cc\u9762\u4f20\u8fc7\u6765\u4e86\uff0c\u6211\u611f\u89c9\u8fd9\u6837\u628a\u7ed3\u679c\u653e\u5230 request \u7684 Body \u91cc\u54cd\u5e94\u4e0d\u592a\u5408\u7406\uff0c\u53c8\u8bf4\u4e0d\u4e0a\u6765\u4e3a\u5565\uff0c\u6709\u5927\u4f6c\u80fd\u89e3\u91ca\u4e00\u4e0b\u5417\uff1f<\/p>\n<\/li>\n<li>\n<p>\u53e6\u5916\u8bf7\u6559\u4e00\u4e0b\u66f4\u597d\u7684\u5b9e\u73b0\u65b9\u5f0f\u662f\u4ec0\u4e48\uff1f<\/p>\n<\/li>\n<\/ul><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>13<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3941445\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Leigg <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f20\u8fc7\u6765\uff1f callbackURL \u4e0d\u5e94\u8be5\u76f4\u63a5\u662f\u9700\u8981\u7ed3\u679c\u7684\u670d\u52a1\u63d0\u4f9b\u7684\uff1f\u4f60\u8fd9\u591a\u5c11\u4e2a\u8bf7\u6c42\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3941446\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : suke971219 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u548c responese \u7684 body \u5e94\u8be5\u662f\u4e00\u6837\u7684 field Body io.ReadCloser \u7c7b\u578b\uff0c\u76f4\u63a5 json decode \u5c31\u884c                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3941447\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : coool <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @suke971219 \u867d\u7136\u7c7b\u578b\u4e00\u6837\uff0c\u901a\u8fc7 request \u7684 body \u4f20\u9012\u7ed3\u679c\u6ca1\u4ec0\u4e48\u4e0d\u59a5\u5417\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3941448\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : coool <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Leigg \u8baf\u98de\u7684\u6587\u6863\u5c31\u662f\u8fd9\u6837\u7684\uff0c\u6211\u4eec\u8bf7\u6c42\u8bed\u97f3\u5904\u7406\u65f6\u8bbe\u7f6e\u4e00\u4e2a callback url\uff0c\u4ed6\u4eec\u5229\u7528\u8fd9\u4e2a url \u901a\u77e5\u6211\u4eec\u7ed3\u679c\u5df2\u7ecf\u5904\u7406\u5b8c\u6210\uff0c\u7136\u540e\u6211\u4eec\u518d\u53bb\u8baf\u98de\u7684 \/getResult \u63a5\u53e3\u62ff\u7ed3\u679c\u3002 \uff08 callback \u7684\u53ea\u505a\u901a\u77e5\uff09                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3941449\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : GuangXiN <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @coool \u6ca1\u6709\u4ec0\u4e48\u4e0d\u59a5\u554a\uff0cbody \u672c\u6765\u5c31\u662f\u8bbe\u8ba1\u6765\u53d1\u9001\u4fe1\u606f\u7528\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3941450\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : GuangXiN <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8baf\u98de\u539f\u672c\u7684\u63a5\u53e3\u8bbe\u8ba1\u624d\u5947\u602a\u597d\u5427\uff0c\u90fd callback \u4e86\u8fd8\u4e0d\u628a\u7ed3\u679c\u4f20\u8fc7\u6765\uff0c\u4ed6\u7684\u7ed3\u679c\u662f\u8bed\u97f3\u8bc6\u522b\u51fa\u6765\u7684\u6587\u5b57\uff0c\u53c8\u4e0d\u662f\u4ec0\u4e48\u89c6\u9891\u4e4b\u7c7b\u7684\u5de8\u578b\u6570\u636e\uff0c\u975e\u5f97\u8ba9\u4eba\u518d\u4e3b\u52a8\u62c9\u53d6\u4e00\u6b21\u7ed3\u679c\uff0c\u8fd9\u4e0d\u662f\u6298\u817e\u4eba\u5417\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3941451\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : suke971219 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @coool #3 \u6211\u4ee5\u4e3a\u662f callback \u7684 request body \u7ed9\u7684\u5185\u5bb9\uff0c\u7ed3\u679c\u4e0d\u662f\uff0c\uff0c \u4f60\u53d1\u8d77\u7684\u8bf7\u6c42\uff0c\u7ed3\u679c\u5e94\u8be5\u5728 response body \u554a\uff0c\u6211\u53bb\u8baf\u98de\u770b\u770b\u53bb                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3941452\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : coool <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @suke971219 \u6211\u540c\u4e8b\u662f\u5728 callback \u62ff\u5230\u8baf\u98de\u7684\u901a\u77e5\u6d88\u606f\u4e4b\u540e\u53bb getResult \u62ff\u7ed3\u679c\uff0c\u7136\u540e\u7ed9\u6211\u4eec\u8fd9\u8fb9\u53d1\u8bf7\u6c42\uff0c\u628a\u8baf\u98de\u7684\u7ed3\u679c\u653e\u5230\u4ed6\u7684\u8bf7\u6c42\u4f53\u4f20\u7ed9\u6211\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3941453\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : coool <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @GuangXiN \u989d\uff0c\u90a3\u597d\uff0c\u6211\u5c31\u76f4\u63a5\u89e3\u6790\u4ed6\u7684\u8bf7\u6c42\u4f53\u62ff\u7ed3\u679c\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3941454\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : THESDZ <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @coool \u540c\u4e8b\u5e94\u8be5\u662f\u60f3\u5c01\u88c5\u4e00\u4e2a\u56de\u8c03\u51fd\u6570\u7684\u63a5\u53e3\u7ed9\u4f60,\u4f60\u5199\u4e2a\u5b9e\u73b0\u8fd9\u6837\u5b50&#8230;\u653e\u5728 request \u7684 body,\u5982\u679c\u662f http \u90a3\u4e2a req \u5c31\u6bd4\u8f83\u8ff7\u832b,\u5982\u679c\u662f callback \u63a5\u53e3\u7684 req(\u5165\u53c2)\u6bd4\u8f83\u5408\u7406                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3941455\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : suke971219 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @coool #8 <img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/10\/9kZ3y873-65.png\" alt=\"golang \u7684 http \u56de\u8c03\u7ed3\u679c\u5982\u4f55\u8fd4\u56de\uff1f\"> \u8fd9\u624d\u770b\u61c2\uff0c\u6211\u8fd9\u4e2a\u8111\u5b50                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3941456\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : coool <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @THESDZ \u4ed6\u5c31\u662f\u5c01\u88c5\u4e86\u56de\u8c03\uff0c\u539f\u672c\u6211\u4eec\u7684\u6d41\u7a0b\u662f\u76d1\u542c callback \u5730\u5740&#8211;\u300b\u83b7\u5f97\u901a\u77e5&#8211;\u300b\u8c03\u7528 \/getResult \u83b7\u53d6\u7ed3\u679c\uff0c\u4ed6\u5c01\u88c5\u4e86\u4e4b\u540e\u5c31\u662f\u6d41\u7a0b\u5c31\u53d8\u6210\u4e86\u76d1\u542c callback&#8211;\u300b\u4ece callback \u7684 request.Body \u83b7\u53d6\u7ed3\u679c\u3002\u6211\u662f\u89c9\u5f97\u628a\u7ed3\u679c\u653e\u5230 request \u91cc\u6709\u70b9\u5947\u602a\uff0c\u6240\u4ee5\u6765\u8bf7\u6559\u4e00\u4e0b\u3002\u6ca1\u95ee\u9898\u7684\u8bdd\u5c31\u662f\u6211\u5b64\u964b\u5be1\u95fb\u4e86\u3002\u3002<\/p>\n<p>### \u8baf\u98de\u6587\u6863<\/p>\n<p>&#8220;`<br \/>\u7ed3\u679c\u56de\u8c03<br \/>\u7528\u6237\u8c03\u7528 upload \u63a5\u53e3\u65f6\uff0c\u5982\u679c\u4e0a\u4f20\u53c2\u6570\u4e2d\u586b\u5199\u4e86\u6b63\u786e\u56de\u8c03\u5730\u5740\uff08 callbackUrl \uff09\u3002\u8ba2\u5355\u5904\u7406\u5b8c\u6bd5\u540e\uff0c\u670d\u52a1\u7aef\u4f1a\u81ea\u52a8\u56de\u8c03\u8be5\u5730\u5740\uff0c\u901a\u77e5\u7528\u6237\u8ba2\u5355\u5df2\u7ecf\u5904\u7406\u5b8c\u6210\uff0c\u8fd4\u56de\u5982\u4e0b\u6570\u636e\u7ed3\u679c\uff1a<br \/>callbackUrl?status=1&amp;orderId=DKHJQ2017120109000003 <br \/>\u53c2\u6570\u8be6\u7ec6\u8bf4\u660e\u5982\u4e0b<\/p>\n<p>\u6ce8\uff1a\u7ed3\u679c\u56de\u8c03\u4ec5\u7528\u4e8e\u901a\u77e5\u7528\u6237\u8ba2\u5355\u5df2\u5904\u7406\u5b8c\u6210\uff0c\u4ecd\u9700\u8981\u8c03\u7528 getResult \u63a5\u53e3\u83b7\u53d6\u8bc6\u522b\u7ed3\u679c\u3002\u82e5\u6ca1\u6709\u6536\u5230\u56de\u8c03\u901a\u77e5\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7\u8f6e\u8be2\u7684\u65b9\u5f0f\u53bb\u83b7\u53d6\u6307\u5b9a\u8ba2\u5355\u53f7\u7684\u8bc6\u522b\u7ed3\u679c\u3002\u8f6e\u8be2\u95f4\u9694\u7684\u65f6\u95f4\u4e0d\u5b9c\u8fc7\u77ed\uff0c\u9700\u6839\u636e\u97f3\u9891\u957f\u77ed\u8bbe\u7f6e\u4e00\u4e2a\u5408\u9002\u7684\u503c\u3002\u5982\u679c\u4e0d\u662f\u6025\u4e8e\u83b7\u53d6\u8bc6\u522b\u7ed3\u679c\uff0c\u5efa\u8bae\u4e00\u5929\u6279\u91cf\u83b7\u53d6\u4e00\u6b21\u3002<br \/>&#8220;`                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3941457\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Seanfuck <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5c01\u88c5\u540e\u5c11\u4e86\u4e00\u4e2a\u62c9\u7ed3\u679c\u7684\u6b65\u9aa4\uff1f\u8fd9\u4e0d\u662f\u7b80\u5316\u4e86\u66f4\u597d\u5417\uff0c\u770b\u770b 6 \u8bf4\u7684\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>golang \u7684 http \u56de\u8c03\u7ed3&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/180109"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=180109"}],"version-history":[{"count":1,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/180109\/revisions"}],"predecessor-version":[{"id":180111,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/180109\/revisions\/180111"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=180109"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=180109"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=180109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}