{"id":91634,"date":"2026-08-08T08:08:59","date_gmt":"2026-08-08T00:08:59","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/91634.html"},"modified":"2026-08-08T08:08:59","modified_gmt":"2026-08-08T00:08:59","slug":"01-%e6%90%ad%e6%9c%8d%e5%8a%a1%e5%99%a8%ef%bc%9a%e5%a4%84%e7%90%86%e5%99%a8%e3%80%81%e8%b7%af%e7%94%b1%e8%a1%a8%e3%80%81%e8%af%bb%e8%af%b7%e6%b1%82%e5%8f%82%e6%95%b0%ef%bc%88%e7%bb%86%e8%ae%b2","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/91634.html","title":{"rendered":"01. \u642d\u670d\u52a1\u5668\uff1a\u5904\u7406\u5668\u3001\u8def\u7531\u8868\u3001\u8bfb\u8bf7\u6c42\u53c2\u6570\uff08\u7ec6\u8bb2\uff09"},"content":{"rendered":"<p>&#x1f970;\u4e2a\u4eba\u4e3b\u9875&#xff1a;\u4f1a\u7f16\u7a0b\u7684\u571f\u8c46&#xff08;\u6b22\u8fce\u6765\u8bbf&#xff09;<img loading=\"lazy\" decoding=\"async\" alt=\"\" class=\"right\" height=\"113\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260808000858-6a76739a86bf2.gif\" width=\"200\" \/> &#x1f48e;\u4f5c\u8005\u7b80\u4ecb&#xff1a;\u540e\u7aef\u5b66\u4e60\u8005 \u2744\ufe0f\u4e2a\u4eba\u4e13\u680f&#xff1a;\u6570\u636e\u7ed3\u6784\u4e0e\u7b97\u6cd5&#xff0c;\u6570\u636e\u5e93&#xff0c;leetcode \u2728\u90a3\u4e9b\u4f60\u4e00\u4e2a\u4eba\u8d70\u8fc7\u7684\u591c\u8def&#xff0c;\u7ec8\u5c06\u5316\u4f5c\u7167\u4eae\u672a\u6765\u7684\u5149<\/p>\n<p style=\"text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"170\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260808000858-6a76739aa9ba1.gif\" width=\"150\" \/><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"170\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260808000858-6a76739abbc67.gif\" width=\"150\" \/><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"170\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260808000858-6a76739ad2171.gif\" width=\"150\" \/><\/p>\n<p>\u5bf9\u5e94\u8bfe&#xff1a;\u642d\u5efa\u670d\u52a1\u5668\u3001HTTP \u534f\u8bae\u3001\u5904\u7406\u8bf7\u6c42\u3001\u7ed9\u5ba2\u6237\u7aef\u54cd\u5e94\u3001\u8bfb\u53c2\u6570&#xff08;\u7ea6 5.4 \u8282\u91cd\u70b9&#xff09; \u4ee3\u7801\u793a\u4f8b\u6765\u81ea\u00a0bookstore0612&#xff0c;\u8def\u5f84&#xff1a;C:\\\\Users\\\\zjl\\\\Projects\\\\goweb-bookstore<\/p>\n<hr \/>\n<h3>\u4e00\u3001\u6700\u5c0f\u53ef\u8fd0\u884c\u670d\u52a1\u5668&#xff08;HelloWorld \u9010\u884c&#xff09;<\/h3>\n<h4>1.1 \u5b8c\u6574\u4ee3\u7801<\/h4>\n<p>package main<\/p>\n<p>import (<br \/>\n    &#034;fmt&#034;<br \/>\n    &#034;net\/http&#034;<br \/>\n)<\/p>\n<p>func hello(w http.ResponseWriter, r *http.Request) {<br \/>\n    fmt.Fprintln(w, &#034;Hello World&#034;)<br \/>\n}<\/p>\n<p>func main() {<br \/>\n    http.HandleFunc(&#034;\/hello&#034;, hello)<br \/>\n    http.ListenAndServe(&#034;:8080&#034;, nil)<br \/>\n}<\/p>\n<p>\u4fdd\u5b58\u4e3a\u00a0main.go&#xff0c;\u5728\u9879\u76ee\u6839\u6267\u884c&#xff1a;<\/p>\n<p>go run main.go<\/p>\n<p>\u6d4f\u89c8\u5668\u8bbf\u95ee\u00a0http:\/\/localhost:8080\/hello&#xff0c;\u9875\u9762\u663e\u793a\u00a0Hello World&#xff08;\u540e\u9762\u53ef\u80fd\u591a\u4e00\u4e2a\u6362\u884c&#xff0c;\u6765\u81ea\u00a0Fprintln&#xff09;\u3002<\/p>\n<h4>1.2 \u9010\u884c\u89e3\u91ca<\/h4>\n<table>\n<tr>\u884c\u4ee3\u7801\u542b\u4e49<\/tr>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>package main<\/td>\n<td>\u53ef\u6267\u884c\u7a0b\u5e8f\u5fc5\u987b\u662f\u00a0main\u00a0\u5305<\/td>\n<\/tr>\n<tr>\n<td>4~5<\/td>\n<td>import &#034;net\/http&#034;<\/td>\n<td>\u6807\u51c6\u5e93 HTTP \u5305&#xff0c;\u8def\u7531\u3001\u670d\u52a1\u5668\u3001Cookie \u90fd\u5728\u8fd9<\/td>\n<\/tr>\n<tr>\n<td>7~9<\/td>\n<td>func hello(w, r)<\/td>\n<td>\u5904\u7406\u5668\u51fd\u6570&#xff1a;\u5904\u7406\u4e00\u6b21\u8bf7\u6c42&#xff1b;\u56fa\u5b9a\u7b7e\u540d\u4e24\u4e2a\u53c2\u6570<\/td>\n<\/tr>\n<tr>\n<td>8<\/td>\n<td>fmt.Fprintln(w, &#034;Hello World&#034;)<\/td>\n<td>\u5f80\u54cd\u5e94\u4f53\u5199\u6587\u672c&#xff1b;w\u00a0\u5b9e\u73b0\u4e86\u00a0io.Writer<\/td>\n<\/tr>\n<tr>\n<td>12<\/td>\n<td>http.HandleFunc(&#034;\/hello&#034;, hello)<\/td>\n<td>\u767b\u8bb0\u8def\u7531&#xff1a;\u8def\u5f84 \u2192 \u51fd\u6570&#xff08;\u6ce8\u610f\u4f20\u7684\u662f\u51fd\u6570\u540d&#xff0c;\u4e0d\u662f\u00a0hello()&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>13<\/td>\n<td>http.ListenAndServe(&#034;:8080&#034;, nil)<\/td>\n<td>\u963b\u585e\u76d1\u542c 8080&#xff1b;nil\u00a0&#061; \u4f7f\u7528\u9ed8\u8ba4\u8def\u7531\u8868<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>1.3 \u4e24\u4e2a\u6838\u5fc3\u7c7b\u578b<\/h4>\n<p>http.ResponseWriter&#xff08;\u5e38\u540d\u00a0w&#xff09;\u00a0\u2014 \u4ee3\u8868\u300c\u8fd9\u6b21\u8bf7\u6c42\u7684\u54cd\u5e94\u300d&#xff1a;<\/p>\n<ul>\n<li>\u5199\u72b6\u6001\u7801&#xff08;\u9ed8\u8ba4 200&#xff09;<\/li>\n<li>\u5199\u54cd\u5e94\u5934&#xff08;w.Header().Set(&#8230;)&#xff09;<\/li>\n<li>\u5199\u54cd\u5e94\u4f53&#xff08;fmt.Fprintln(w,&#8230;)\u3001w.Write([]byte(&#8230;))&#xff09;<\/li>\n<\/ul>\n<p>http.Request&#xff08;\u5e38\u540d\u00a0r&#xff09;\u00a0\u2014 \u4ee3\u8868\u300c\u6d4f\u89c8\u5668\u53d1\u6765\u7684\u8fd9\u6b21\u8bf7\u6c42\u300d&#xff1a;<\/p>\n<ul>\n<li>URL\u3001Method&#xff08;GET\/POST&#xff09;<\/li>\n<li>\u8bf7\u6c42\u5934\u3001Cookie<\/li>\n<li>\u8bf7\u6c42\u4f53&#xff08;POST \u8868\u5355\u3001JSON \u7b49&#xff09;<\/li>\n<\/ul>\n<h4>1.4 \u5904\u7406\u5668\u51fd\u6570 &#061; \u8bfe\u91cc\u7684\u300c\u5904\u7406\u8bf7\u6c42\u7684\u51fd\u6570\u300d<\/h4>\n<p>\u4e66\u57ce\u9879\u76ee\u91cc\u6bcf\u4e00\u4e2a\u00a0controller.Login\u3001controller.AddBook2Cart\u00a0\u90fd\u662f\u8fd9\u79cd\u7b7e\u540d&#xff1a;<\/p>\n<p>func Login(w http.ResponseWriter, r *http.Request) { &#8230; }<\/p>\n<p>\u4e00\u6b21 HTTP \u8bf7\u6c42 \u2192 \u8c03\u7528\u4e00\u6b21\u5904\u7406\u5668\u51fd\u6570\u3002<\/p>\n<hr \/>\n<h3>\u4e8c\u3001\u4e09\u79cd\u6302\u6cd5&#xff1a;HandleFunc\u3001Handle\u3001ServeHTTP<\/h3>\n<h4>2.1 \u65b9\u5f0f\u4e00&#xff1a;HandleFunc \u2014\u2014 \u6302\u666e\u901a\u51fd\u6570&#xff08;\u4e66\u57ce 99% \u7528\u6cd5&#xff09;<\/h4>\n<p>http.HandleFunc(&#034;\/login&#034;, controller.Login)<\/p>\n<ul>\n<li>\u7b2c\u4e00\u4e2a\u53c2\u6570&#xff1a;URL \u8def\u5f84&#xff08;\u7cbe\u786e\u5339\u914d&#xff0c;\u8bfe\u91cc\u9636\u6bb5\u4e0d\u505a\u6b63\u5219&#xff09;<\/li>\n<li>\u7b2c\u4e8c\u4e2a\u53c2\u6570&#xff1a;\u7b26\u5408\u00a0func(w,r)\u00a0\u7b7e\u540d\u7684\u51fd\u6570<\/li>\n<\/ul>\n<p>\u5185\u90e8\u539f\u7406&#xff08;\u4e86\u89e3\u5373\u53ef&#xff09;&#xff1a;\u00a0HandleFunc\u00a0\u4f1a\u628a\u4f60\u7684\u51fd\u6570\u5305\u88c5\u6210\u4e00\u4e2a\u5b9e\u73b0\u4e86\u00a0ServeHTTP\u00a0\u7684\u5bf9\u8c61&#xff0c;\u518d\u6ce8\u518c\u5230 Mux\u3002<\/p>\n<h4>2.2 \u65b9\u5f0f\u4e8c&#xff1a;Handle \u2014\u2014 \u6302\u300c\u5bf9\u8c61\u300d<\/h4>\n<p>type MyHandler struct{}<\/p>\n<p>func (m *MyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {<br \/>\n    fmt.Fprintln(w, &#034;\u6b63\u5728\u901a\u8fc7\u5904\u7406\u5668\u5904\u7406\u4f60\u7684\u8bf7\u6c42&#034;)<br \/>\n}<\/p>\n<p>func main() {<br \/>\n    myHandler :&#061; MyHandler{}<br \/>\n    http.Handle(&#034;\/&#034;, &amp;myHandler)  \/\/ \u6ce8\u518c\u7684\u662f\u6307\u9488 &amp;myHandler<br \/>\n    http.ListenAndServe(&#034;:8080&#034;, nil)<br \/>\n}<\/p>\n<p>\u8981\u70b9&#xff1a;<\/p>\n<table>\n<tr>\u7ec6\u8282\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>\u65b9\u6cd5\u540d\u5fc5\u987b\u53eb\u00a0ServeHTTP<\/td>\n<td>\u8fd9\u662f\u00a0http.Handler\u00a0\u63a5\u53e3\u89c4\u5b9a\u7684<\/td>\n<\/tr>\n<tr>\n<td>\u6ce8\u518c\u65f6\u7528\u00a0&amp;myHandler<\/td>\n<td>\u6307\u9488\u63a5\u6536\u8005&#xff0c;\u907f\u514d\u62f7\u8d1d<\/td>\n<\/tr>\n<tr>\n<td>Handle\u00a0\u4e0d\u662f\u7acb\u523b\u8c03\u7528<\/td>\n<td>\u53ea\u662f\u767b\u8bb0&#xff1b;\u8bf7\u6c42\u6765\u4e86\u624d\u6267\u884c<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>2.3 \u65b9\u5f0f\u4e09&#xff1a;ServeHTTP \u2014\u2014 \u63a5\u53e3\u672c\u8d28<\/h4>\n<p>type Handler interface {<br \/>\n    ServeHTTP(ResponseWriter, *Request)<br \/>\n}<\/p>\n<p>\u8c01\u5b9e\u73b0\u4e86\u8fd9\u4e2a\u63a5\u53e3&#xff0c;\u8c01\u5c31\u53ef\u4ee5\u88ab\u00a0http.Handle(path, handler)\u00a0\u6ce8\u518c\u3002<\/p>\n<p>\u5bf9\u6bd4\u8868&#xff1a;<\/p>\n<table>\n<tr>API\u6ce8\u518c\u76ee\u6807\u5178\u578b\u573a\u666f<\/tr>\n<tbody>\n<tr>\n<td>HandleFunc(path, fn)<\/td>\n<td>\u51fd\u6570<\/td>\n<td>\u4e66\u57ce\u6240\u6709\u4e1a\u52a1\u5904\u7406\u5668<\/td>\n<\/tr>\n<tr>\n<td>Handle(path, obj)<\/td>\n<td>\u5b9e\u73b0\u4e86\u00a0Handler\u00a0\u7684\u5bf9\u8c61<\/td>\n<td>http.FileServer\u3001http.StripPrefix\u00a0\u8fd4\u56de\u503c<\/td>\n<\/tr>\n<tr>\n<td>\u76f4\u63a5\u5199\u00a0ServeHTTP<\/td>\n<td>\u81ea\u5b9a\u4e49\u7c7b\u578b<\/td>\n<td>\u8bfe\u91cc\u6f14\u793a\u3001\u6807\u51c6\u5e93\u5185\u90e8<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>2.4 \u4e66\u57ce main.go \u91cc\u7684\u771f\u5b9e\u6ce8\u518c<\/h4>\n<p>\/\/ \u9759\u6001\u8d44\u6e90&#xff1a;Handle &#043; FileServer&#xff08;FileServer \u672c\u8eab\u5b9e\u73b0\u4e86 Handler&#xff09;<br \/>\nhttp.Handle(&#034;\/static\/&#034;, http.StripPrefix(&#034;\/static\/&#034;, http.FileServer(http.Dir(&#034;views\/static&#034;))))<\/p>\n<p>\/\/ \u52a8\u6001\u4e1a\u52a1&#xff1a;HandleFunc &#043; controller \u51fd\u6570<br \/>\nhttp.HandleFunc(&#034;\/login&#034;, controller.Login)<br \/>\nhttp.HandleFunc(&#034;\/addBook2Cart&#034;, controller.AddBook2Cart)<\/p>\n<p>\u672c\u8d28\u90fd\u662f&#xff1a;URL \u2192 \u67d0\u79cd\u5904\u7406\u903b\u8f91\u3002<\/p>\n<hr \/>\n<h3>\u4e09\u3001\u8def\u7531\u8868 ServeMux \u2014\u2014 \u7528\u300c\u7535\u8bdd\u603b\u673a\u300d\u7c7b\u6bd4<\/h3>\n<h4>3.1 \u662f\u4ec0\u4e48<\/h4>\n<p>\u8def\u7531\u8868&#xff08;ServeMux&#xff09;\u5c31\u662f\u4e00\u5f20\u00a0URL \u2192 \u5904\u7406\u5668\u00a0\u7684\u5bf9\u7167\u8868&#xff1a;<\/p>\n<p>\/login        \u2192 controller.Login<br \/>\n\/regist       \u2192 controller.Regist<br \/>\n\/main         \u2192 controller.GetPageBooksByPrice<br \/>\n\/addBook2Cart \u2192 controller.AddBook2Cart<br \/>\n&#8230;<\/p>\n<p>\u7c7b\u6bd4&#xff1a;\u516c\u53f8\u603b\u673a\u3002\u5ba2\u6237\u62e8\u5206\u673a\u53f7&#xff08;URL&#xff09;&#xff0c;\u603b\u673a\u67e5\u8868\u8f6c\u63a5\u5230\u5bf9\u5e94\u90e8\u95e8&#xff08;\u5904\u7406\u5668&#xff09;\u3002<\/p>\n<h4>3.2 DefaultServeMux&#xff08;\u9ed8\u8ba4\u603b\u673a&#xff09;<\/h4>\n<p>http.HandleFunc(&#034;\/login&#034;, controller.Login)<br \/>\nhttp.ListenAndServe(&#034;:8080&#034;, nil)  \/\/ \u7b2c\u4e8c\u4e2a\u53c2\u6570 nil \u2192 \u7528 DefaultServeMux<\/p>\n<ul>\n<li>Go \u5728\u00a0net\/http\u00a0\u5305\u91cc\u9884\u7f6e\u4e86\u5168\u5c40\u53d8\u91cf\u00a0DefaultServeMux<\/li>\n<li>http.HandleFunc\u00a0\/\u00a0http.Handle\u00a0\u5b9e\u9645\u662f\u5f80\u00a0DefaultServeMux\u00a0\u4e0a\u6ce8\u518c<\/li>\n<li>\u4e00\u5f00\u59cb\u8868\u662f\u7a7a\u7684&#xff0c;\u6240\u6709\u4e1a\u52a1\u8def\u5f84\u90fd\u662f\u4f60\u81ea\u5df1\u6302\u4e0a\u53bb\u7684<\/li>\n<li>\u300c\u9ed8\u8ba4\u300d\u2260 \u5185\u7f6e\u4e86\u00a0\/login&#xff1b;\u53ea\u662f\u300c\u9ed8\u8ba4\u7528\u8fd9\u4e00\u5f20\u8868\u300d<\/li>\n<\/ul>\n<h4>3.3 NewServeMux&#xff08;\u81ea\u5df1\u4e70\u4e00\u53f0\u603b\u673a&#xff09;<\/h4>\n<p>mux :&#061; http.NewServeMux()<br \/>\nmux.HandleFunc(&#034;\/myMux&#034;, myHandler)<br \/>\nhttp.ListenAndServe(&#034;:8080&#034;, mux)  \/\/ \u5fc5\u987b\u4f20\u5165 mux&#xff0c;\u4e0d\u80fd nil<\/p>\n<table>\n<tr>\u5199\u6cd5\u8def\u7531\u8868\u6548\u679c<\/tr>\n<tbody>\n<tr>\n<td>ListenAndServe(&#034;:8080&#034;, nil)<\/td>\n<td>DefaultServeMux<\/td>\n<td>\u7528\u5305\u7ea7\u00a0HandleFunc\u00a0\u6ce8\u518c\u7684\u90fd\u80fd\u547d\u4e2d<\/td>\n<\/tr>\n<tr>\n<td>ListenAndServe(&#034;:8080&#034;, mux)<\/td>\n<td>\u81ea\u5b9a\u4e49 mux<\/td>\n<td>\u53ea\u6709\u00a0mux.HandleFunc\u00a0\u6ce8\u518c\u7684\u80fd\u547d\u4e2d<\/td>\n<\/tr>\n<tr>\n<td>HandleFunc\u00a0&#043;\u00a0ListenAndServe(&#8230;, mux)\u00a0\u6df7\u7528<\/td>\n<td>\u5206\u88c2<\/td>\n<td>\u6ce8\u518c\u5728 Default \u4e0a\u7684\u8def\u5f84\u5728\u81ea\u5b9a\u4e49 mux \u4e0a\u00a0404<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4f55\u65f6\u6548\u679c\u4e0d\u540c&#xff08;\u6613\u9519&#xff09;&#xff1a;<\/p>\n<p>http.HandleFunc(&#034;\/a&#034;, handlerA)           \/\/ \u6ce8\u518c\u5728 DefaultServeMux<br \/>\nmux :&#061; http.NewServeMux()<br \/>\nmux.HandleFunc(&#034;\/b&#034;, handlerB)<br \/>\nhttp.ListenAndServe(&#034;:8080&#034;, mux)         \/\/ \u53ea\u6709 \/b \u6709\u6548&#xff0c;\/a \u4f1a 404&#xff01;<\/p>\n<p>\u4e66\u57ce\u8bfe\u91cc\u4e3a\u4e86\u8bb2\u6e05\u6982\u5ff5\u4f1a\u5199\u00a0NewServeMux&#xff1b;\u5165\u95e8\u9879\u76ee\u7528 DefaultServeMux &#043; nil \u8db3\u591f&#xff0c;\u548c\u81ea\u5b9a\u4e49 mux \u5728\u300c\u53ea\u7528\u4e00\u4e2a\u8868\u300d\u65f6\u6548\u679c\u51e0\u4e4e\u4e00\u6837\u3002<\/p>\n<h4>3.4 \u8def\u5f84\u5339\u914d\u89c4\u5219&#xff08;\u8bfe\u91cc\u5e38\u7528\u5b50\u96c6&#xff09;<\/h4>\n<ul>\n<li>\u6ce8\u518c\u00a0\/static\/\u00a0\u8fd9\u79cd\u5e26\u5c3e\u90e8\u00a0\/\u00a0\u7684\u524d\u7f00&#xff0c;\u4f1a\u5339\u914d\u00a0\/static\/css\/style.css<\/li>\n<li>\u7cbe\u786e\u8def\u5f84\u5982\u00a0\/login\u00a0\u53ea\u5339\u914d\u00a0\/login&#xff08;\u4e0d\u542b query&#xff1a;\/login?x&#061;1\u00a0\u4ecd\u5339\u914d&#xff09;<\/li>\n<li>\u6839\u8def\u5f84\u00a0\/\u00a0\u5728\u4e66\u57ce\u7528\u533f\u540d\u51fd\u6570\u5355\u72ec\u5904\u7406&#xff0c;\u907f\u514d\u62a2\u8d70\u6240\u6709 404<\/li>\n<\/ul>\n<hr \/>\n<h3>\u56db\u3001http.Server \u7ed3\u6784\u4f53&#xff08;\u81ea\u5b9a\u4e49\u670d\u52a1\u5668&#xff09;<\/h3>\n<h4>4.1 \u57fa\u672c\u5199\u6cd5<\/h4>\n<p>import &#034;time&#034;<\/p>\n<p>server :&#061; http.Server{<br \/>\n    Addr:         &#034;:8080&#034;,       \/\/ \u76d1\u542c\u5730\u5740<br \/>\n    Handler:      nil,           \/\/ nil \u5219\u5185\u90e8\u7528 DefaultServeMux<br \/>\n    ReadTimeout:  5 * time.Second,<br \/>\n    WriteTimeout: 10 * time.Second,<br \/>\n    IdleTimeout:  120 * time.Second,<br \/>\n}<br \/>\nserver.ListenAndServe()<\/p>\n<h4>4.2 \u5e38\u7528\u5b57\u6bb5<\/h4>\n<table>\n<tr>\u5b57\u6bb5\u4f5c\u7528<\/tr>\n<tbody>\n<tr>\n<td>Addr<\/td>\n<td>\u5982\u00a0:8080\u3001127.0.0.1:8080<\/td>\n<\/tr>\n<tr>\n<td>Handler<\/td>\n<td>\u6839\u5904\u7406\u5668&#xff0c;\u901a\u5e38\u662f\u00a0nil\u3001*ServeMux\u00a0\u6216\u81ea\u5b9a\u4e49\u00a0Handler<\/td>\n<\/tr>\n<tr>\n<td>ReadTimeout<\/td>\n<td>\u8bfb\u6574\u4e2a\u8bf7\u6c42&#xff08;\u542b body&#xff09;\u7684\u6700\u957f\u65f6\u95f4<\/td>\n<\/tr>\n<tr>\n<td>WriteTimeout<\/td>\n<td>\u5199\u54cd\u5e94\u7684\u6700\u957f\u65f6\u95f4<\/td>\n<\/tr>\n<tr>\n<td>IdleTimeout<\/td>\n<td>HTTP\/1.1 keep-alive \u7a7a\u95f2\u8fde\u63a5\u8d85\u65f6<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>4.3 \u81f4\u547d\u6613\u9519\u70b9<\/h4>\n<p>server :&#061; http.Server{<br \/>\n    Addr:    &#034;:8080&#034;,<br \/>\n    Handler: myMux,<br \/>\n    ReadTimeout: 2 * time.Second,<br \/>\n}<br \/>\n\/\/ \u9519&#xff1a;\u8fd9\u6837 ListenAndServe \u4e0d\u4f1a\u7528\u5230\u4e0a\u9762 server \u7684\u914d\u7f6e&#xff01;<br \/>\nhttp.ListenAndServe(&#034;:8080&#034;, nil)<\/p>\n<p>\/\/ \u5bf9&#xff1a;\u5fc5\u987b\u8c03\u5b9e\u4f8b\u65b9\u6cd5<br \/>\nserver.ListenAndServe()<\/p>\n<p>\u89c4\u5219&#xff1a;\u00a0\u914d\u4e86\u00a0http.Server{&#8230;}\u00a0\u5c31\u5fc5\u987b\u00a0server.ListenAndServe()&#xff0c;\u5426\u5219\u81ea\u5b9a\u4e49 Handler\u3001\u8d85\u65f6\u00a0\u5168\u90e8\u4e0d\u751f\u6548\u3002<\/p>\n<p>\u4e66\u57ce\u5b8c\u6574\u7248\u4e3a\u7b80\u6d01\u76f4\u63a5\u7528&#xff1a;<\/p>\n<p>http.ListenAndServe(&#034;:8080&#034;, nil)<\/p>\n<hr \/>\n<h3>\u4e94\u3001HTTP \u62a5\u6587\u89e3\u5256&#xff08;\u5e26\u4e66\u57ce\u767b\u5f55\u5b9e\u4f8b&#xff09;<\/h3>\n<h4>5.1 \u8bf7\u6c42\u62a5\u6587&#xff08;\u6d4f\u89c8\u5668 \u2192 \u670d\u52a1\u5668&#xff09;<\/h4>\n<p>\u4ee5\u767b\u5f55 POST \u4e3a\u4f8b&#xff1a;<\/p>\n<p>POST \/login HTTP\/1.1                          \u2190 \u8bf7\u6c42\u884c&#xff1a;\u65b9\u6cd5 &#043; \u8def\u5f84 &#043; \u534f\u8bae\u7248\u672c<br \/>\nHost: localhost:8080                          \u2190 \u8bf7\u6c42\u5934\u5f00\u59cb<br \/>\nUser-Agent: Mozilla\/5.0 &#8230;<br \/>\nAccept: text\/html,application\/xhtml&#043;xml,&#8230;<br \/>\nContent-Type: application\/x-www-form-urlencoded<br \/>\nContent-Length: 32<br \/>\nCookie: user&#061;abc-def-ghi                       \u2190 \u82e5\u4e4b\u524d\u767b\u5f55\u8fc7&#xff0c;\u4f1a\u5e26\u4e0a<\/p>\n<p>username&#061;admin&amp;password&#061;123456                 \u2190 \u7a7a\u884c\u540e\u662f\u8bf7\u6c42\u4f53&#xff08;POST \u8868\u5355&#xff09;<\/p>\n<table>\n<tr>\u90e8\u5206\u5185\u5bb9\u5728 Go \u91cc\u600e\u4e48\u8bfb<\/tr>\n<tbody>\n<tr>\n<td>\u8bf7\u6c42\u884c<\/td>\n<td>POST \/login HTTP\/1.1<\/td>\n<td>r.Method\u00a0r.URL.Path<\/td>\n<\/tr>\n<tr>\n<td>\u8bf7\u6c42\u5934<\/td>\n<td>Host\u3001Content-Type\u3001Cookie\u2026<\/td>\n<td>r.Header\u00a0r.Cookie(&#034;user&#034;)<\/td>\n<\/tr>\n<tr>\n<td>\u8bf7\u6c42\u4f53<\/td>\n<td>username&#061;admin&amp;password&#061;123456<\/td>\n<td>ParseForm\u00a0\u540e\u00a0PostForm\u00a0\/\u00a0PostFormValue<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>GET \u793a\u4f8b&#xff08;\u9996\u9875\u7ffb\u9875&#xff09;&#xff1a;<\/p>\n<p>GET \/main?pageNo&#061;2&amp;min&#061;10&amp;max&#061;50 HTTP\/1.1<br \/>\nHost: localhost:8080<\/p>\n<p>\u53c2\u6570\u5728\u00a0URL query&#xff0c;\u4e0d\u5728 body&#xff1b;\u7528\u00a0r.FormValue(&#034;pageNo&#034;)\u00a0\u6216\u00a0r.URL.Query().Get(&#034;pageNo&#034;)\u3002<\/p>\n<h4>5.2 \u54cd\u5e94\u62a5\u6587&#xff08;\u670d\u52a1\u5668 \u2192 \u6d4f\u89c8\u5668&#xff09;<\/h4>\n<p>\u767b\u5f55\u6210\u529f\u65f6\u5927\u81f4\u5982\u4e0b&#xff1a;<\/p>\n<p>HTTP\/1.1 200 OK                               \u2190 \u72b6\u6001\u884c<br \/>\nContent-Type: text\/html; charset&#061;utf-8<br \/>\nSet-Cookie: user&#061;c65d2a76-9447-44cc-&#8230;; Path&#061;\/; HttpOnly<br \/>\nDate: &#8230;<\/p>\n<p>&lt;!DOCTYPE html&gt;                                \u2190 \u54cd\u5e94\u4f53&#xff08;HTML&#xff09;<br \/>\n&lt;html&gt;&#8230;&lt;\/html&gt;<\/p>\n<table>\n<tr>\u72b6\u6001\u7801\u542b\u4e49\u4e66\u57ce\u7528\u6cd5<\/tr>\n<tbody>\n<tr>\n<td>200<\/td>\n<td>OK<\/td>\n<td>\u6b63\u5e38\u8fd4\u56de HTML \/ JSON<\/td>\n<\/tr>\n<tr>\n<td>302<\/td>\n<td>Found<\/td>\n<td>http.Redirect(w,r,&#034;\/main&#034;,http.StatusFound)<\/td>\n<\/tr>\n<tr>\n<td>404<\/td>\n<td>Not Found<\/td>\n<td>http.NotFound(w,r)<\/td>\n<\/tr>\n<tr>\n<td>401<\/td>\n<td>Unauthorized<\/td>\n<td>\u6539\u8d2d\u7269\u8f66\u6570\u91cf\u672a\u767b\u5f55\u65f6\u00a0http.Error(&#8230;, 401)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>5.3 \u5904\u7406\u5668\u91cc\u5199\u54cd\u5e94\u7684\u51e0\u79cd\u65b9\u5f0f<\/h4>\n<p>\/\/ 1. \u7eaf\u6587\u672c<br \/>\nfmt.Fprintln(w, &#034;Hello&#034;)<br \/>\nw.Write([]byte(&#034;\u8bf7\u5148\u767b\u5f55&#xff01;&#034;))<\/p>\n<p>\/\/ 2. \u8df3\u8f6c<br \/>\nhttp.Redirect(w, r, &#034;\/main&#034;, http.StatusFound)<\/p>\n<p>\/\/ 3. HTML \u6a21\u677f&#xff08;\u4e66\u57ce\u4e3b\u6d41&#xff09;<br \/>\nt :&#061; template.Must(template.ParseFiles(&#034;views\/pages\/user\/login.html&#034;))<br \/>\nt.Execute(w, data)<\/p>\n<p>\/\/ 4. JSON&#xff08;\u52a0\u8d2d Ajax&#xff09;<br \/>\nw.Header().Set(&#034;Content-Type&#034;, &#034;application\/json; charset&#061;utf-8&#034;)<br \/>\njson.NewEncoder(w).Encode(map[string]interface{}{&#034;ok&#034;: true, &#034;msg&#034;: &#034;&#8230;&#034;})<\/p>\n<p>\u6ce8\u610f&#xff1a;\u00a0\u82e5\u624b\u52a8\u00a0WriteHeader(404)&#xff0c;\u987b\u5728\u00a0\u4efb\u4f55 body \u5199\u5165\u4e4b\u524d\u00a0\u8c03\u7528\u3002<\/p>\n<hr \/>\n<h3>\u516d\u3001\u8bfb\u8bf7\u6c42\u53c2\u6570&#xff08;\u8bfe 5.4 \u91cd\u70b9 &#043; hanzong\/admin \u5b9e\u9a8c&#xff09;<\/h3>\n<h4>6.1 \u5b9e\u9a8c HTML&#xff08;\u8bfe\u5185\u7ecf\u5178&#xff09;<\/h4>\n<p>&lt;form action&#061;&#034;http:\/\/localhost:8080\/getBody&#034; method&#061;&#034;POST&#034;&gt;<br \/>\n  \u7528\u6237\u540d&#xff1a;&lt;input type&#061;&#034;text&#034; name&#061;&#034;username&#034; value&#061;&#034;hanzong&#034;&gt;&lt;br\/&gt;<br \/>\n  \u5bc6\u7801&#xff1a;&lt;input type&#061;&#034;password&#034; name&#061;&#034;password&#034; value&#061;&#034;666666&#034;&gt;&lt;br\/&gt;<br \/>\n  &lt;input type&#061;&#034;submit&#034;&gt;<br \/>\n&lt;\/form&gt;<\/p>\n<p>\u82e5\u6d4f\u89c8\u5668\u5730\u5740\u680f\u6216 form \u7684 action \u540c\u65f6\u5e26 query&#xff1a;<\/p>\n<p>http:\/\/localhost:8080\/getBody?username&#061;admin<\/p>\n<p>\u5219\u00a0\u540c\u4e00\u6b21 POST\u00a0\u91cc&#xff1a;<\/p>\n<ul>\n<li>URL \u4e0a\u6709\u00a0username&#061;admin<\/li>\n<li>\u8868\u5355 body \u91cc\u6709\u00a0username&#061;hanzong&amp;password&#061;666666<\/li>\n<\/ul>\n<h4>6.2 \u56db\u79cd\u5bb9\u5668 API<\/h4>\n<h5>\u2460\u00a0r.Form\u00a0\u2014 URL &#043; \u8868\u5355 body \u90fd\u8981<\/h5>\n<p>r.ParseForm()  \/\/ \u5fc5\u987b\u5148\u89e3\u6790&#xff01;<br \/>\nfmt.Fprintln(w, r.Form)<br \/>\n\/\/ \u8f93\u51fa\u7c7b\u4f3c&#xff1a;map[username:[hanzong admin] password:[666666]]<\/p>\n<p>\u987a\u5e8f\u89c4\u5219&#xff1a;\u00a0\u540c\u4e00 key \u591a\u4e2a\u503c\u65f6&#xff0c;\u8868\u5355\u5728\u524d&#xff0c;URL query \u5728\u540e&#xff08;slice \u91cc\u00a0hanzong\u00a0\u5728\u00a0admin\u00a0\u524d\u9762&#xff09;\u3002<\/p>\n<p>\u5185\u5b58\u793a\u610f&#xff1a;<\/p>\n<p>r.Form[&#034;username&#034;]  \u2192  []string{&#034;hanzong&#034;, &#034;admin&#034;}<br \/>\n                         \u2191 PostForm \u6765\u7684    \u2191 URL \u6765\u7684<\/p>\n<h5>\u2461\u00a0r.PostForm\u00a0\u2014 \u53ea\u8981 POST body \u91cc\u7684\u8868\u5355<\/h5>\n<p>r.ParseForm()<br \/>\nfmt.Fprintln(w, r.PostForm)<br \/>\n\/\/ map[username:[hanzong] password:[666666]]   \u2190 \u6ca1\u6709 admin<\/p>\n<h5>\u2462\u00a0r.FormValue(&#034;username&#034;)\u00a0\u2014 \u5feb\u6377\u53d6\u300c\u7b2c\u4e00\u4e2a\u503c\u300d<\/h5>\n<p>\/\/ \u5185\u90e8\u4f1a\u81ea\u52a8 ParseForm<br \/>\nv :&#061; r.FormValue(&#034;username&#034;)  \/\/ &#034;hanzong&#034;&#xff08;\u8868\u5355\u4f18\u5148\u4e8e URL \u7684\u7b2c\u4e00\u4e2a&#xff09;<\/p>\n<h5>\u2463\u00a0r.PostFormValue(&#034;username&#034;)\u00a0\u2014 \u53ea\u8ba4 body<\/h5>\n<p>v :&#061; r.PostFormValue(&#034;username&#034;)  \/\/ &#034;hanzong&#034;<br \/>\nv :&#061; r.PostFormValue(&#034;password&#034;)  \/\/ &#034;666666&#034;<\/p>\n<p>\u4e66\u57ce\u767b\u5f55&#xff08;controller\/userhandler.go&#xff09;&#xff1a;<\/p>\n<p>username :&#061; r.PostFormValue(&#034;username&#034;)<br \/>\npassword :&#061; r.PostFormValue(&#034;password&#034;)<br \/>\nuser, _ :&#061; dao.CheckUserNameAndPassword(username, password)<\/p>\n<p>\u4e3a\u4ec0\u4e48\u767b\u5f55\u7528\u00a0PostFormValue&#xff1f;\u5bc6\u7801\u53ea\u5e94\u4ece POST body \u6765&#xff0c;\u907f\u514d\u6709\u4eba\u6784\u9020\u00a0GET \/login?password&#061;xxx\u00a0\u6df7\u8fdb\u53c2\u6570\u3002<\/p>\n<h4>6.3 \u5bf9\u6bd4\u603b\u8868<\/h4>\n<table>\n<tr>API\u6570\u636e\u6765\u6e90\u662f\u5426\u81ea\u52a8 Parse\u8fd4\u56de\u503c\u4e66\u57ce\u573a\u666f<\/tr>\n<tbody>\n<tr>\n<td>ParseForm()<\/td>\n<td>\u524d\u63d0<\/td>\n<td>\u2014<\/td>\n<td>error<\/td>\n<td>\u7528 Form\/PostForm \u524d\u5fc5\u8c03<\/td>\n<\/tr>\n<tr>\n<td>r.Form<\/td>\n<td>URL &#043; body<\/td>\n<td>\u5426<\/td>\n<td>map[string][]string<\/td>\n<td>\u8c03\u8bd5\u3001\u591a\u503c<\/td>\n<\/tr>\n<tr>\n<td>r.PostForm<\/td>\n<td>\u4ec5 body<\/td>\n<td>\u5426<\/td>\n<td>map[string][]string<\/td>\n<td>\u533a\u5206 URL\/\u8868\u5355<\/td>\n<\/tr>\n<tr>\n<td>FormValue(k)<\/td>\n<td>URL &#043; body<\/td>\n<td>\u662f<\/td>\n<td>\u7b2c\u4e00\u4e2a string<\/td>\n<td>\u52a0\u8d2d\u00a0bookId\u3001\u5220\u4e66\u00a0id<\/td>\n<\/tr>\n<tr>\n<td>PostFormValue(k)<\/td>\n<td>\u4ec5 body<\/td>\n<td>\u662f<\/td>\n<td>string<\/td>\n<td>\u767b\u5f55\u3001\u6ce8\u518c<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>6.4 Content-Type \u9650\u5236<\/h4>\n<p>\u4e0a\u8ff0\u00a0Form\u00a0\/\u00a0PostForm\u00a0\u9ed8\u8ba4\u9488\u5bf9&#xff1a;<\/p>\n<p>Content-Type: application\/x-www-form-urlencoded<\/p>\n<p>\u4e0a\u4f20\u6587\u4ef6\u00a0\u65f6\u662f\u00a0multipart\/form-data&#xff0c;\u9700&#xff1a;<\/p>\n<p>r.ParseMultipartForm(maxMemory)<br \/>\nr.MultipartForm.File[&#034;myfile&#034;]<\/p>\n<p>\u4e66\u57ce\u8bfe\u9636\u6bb5\u51e0\u4e4e\u90fd\u662f urlencoded&#xff0c;\u77e5\u9053\u5373\u53ef\u3002<\/p>\n<h4>6.5 Ajax \u4e0e\u8868\u5355\u7684\u4e00\u81f4\u6027<\/h4>\n<p>\u6ce8\u518c\u9875 Ajax \u6821\u9a8c&#xff08;\/checkUserName&#xff09;&#xff1a;<\/p>\n<p>$.post(&#034;\/checkUserName&#034;, {&#034;username&#034;: username}, function(data){ &#8230; });<\/p>\n<p>\u540e\u7aef&#xff1a;<\/p>\n<p>username :&#061; r.PostFormValue(&#034;username&#034;)<\/p>\n<p>jQuery \u7684\u00a0$.post\u00a0\u4f1a\u628a\u5bf9\u8c61\u7f16\u6210\u00a0POST body&#xff0c;\u548c form \u7684\u00a0name&#061;&#034;username&#034;\u00a0\u672c\u8d28\u76f8\u540c\u3002<\/p>\n<p>\u52a0\u8d2d&#xff08;views\/index.html&#xff09;&#xff1a;<\/p>\n<p>$.post(&#034;\/addBook2Cart&#034;, {&#034;bookId&#034;: bookId}, &#8230;);<\/p>\n<p>\u540e\u7aef&#xff1a;<\/p>\n<p>bookID :&#061; r.FormValue(&#034;bookId&#034;)<\/p>\n<p>\u8fd9\u91cc\u7528\u00a0FormValue\u00a0\u4e5f\u884c&#xff0c;\u56e0\u4e3a Ajax \u53ea\u6709 body\u3001\u6ca1\u6709\u51b2\u7a81 URL \u53c2\u6570\u3002<\/p>\n<hr \/>\n<h3>\u4e03\u3001\u9759\u6001\u8d44\u6e90 FileServer&#xff08;\u4e66\u57ce main.go&#xff09;<\/h3>\n<h4>7.1 \u6ce8\u518c\u4ee3\u7801<\/h4>\n<p>http.Handle(&#034;\/static\/&#034;, http.StripPrefix(&#034;\/static\/&#034;, http.FileServer(http.Dir(&#034;views\/static&#034;))))<br \/>\nhttp.Handle(&#034;\/pages\/&#034;, http.StripPrefix(&#034;\/pages\/&#034;, http.FileServer(http.Dir(&#034;views\/pages&#034;))))<\/p>\n<h4>7.2 \u8bf7\u6c42\u5982\u4f55\u6620\u5c04\u5230\u78c1\u76d8<\/h4>\n<table>\n<tr>\u6d4f\u89c8\u5668\u8bf7\u6c42StripPrefix \u540e\u78c1\u76d8\u8def\u5f84<\/tr>\n<tbody>\n<tr>\n<td>\/static\/css\/style.css<\/td>\n<td>css\/style.css<\/td>\n<td>views\/static\/css\/style.css<\/td>\n<\/tr>\n<tr>\n<td>\/pages\/user\/login.html<\/td>\n<td>user\/login.html<\/td>\n<td>views\/pages\/user\/login.html<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>7.3 \u9010\u5c42\u7406\u89e3<\/h4>\n<p>http.FileServer(http.Dir(&#034;views\/static&#034;))<br \/>\n  \u2192 \u5b9e\u73b0\u4e86 Handler&#xff0c;\u6309 URL \u8def\u5f84\u8bfb\u672c\u5730\u6587\u4ef6<\/p>\n<p>http.StripPrefix(&#034;\/static\/&#034;, &#8230;)<br \/>\n  \u2192 \u53bb\u6389 URL \u524d\u7f00&#xff0c;\u5426\u5219\u4f1a\u628a \/static\/ \u4e5f\u5f53\u6210\u76ee\u5f55\u540d<\/p>\n<p>http.Handle(&#034;\/static\/&#034;, &#8230;)<br \/>\n  \u2192 \u6302\u5230 DefaultServeMux<\/p>\n<h4>7.4 login.html \u5982\u4f55\u5f15\u7528\u9759\u6001\u8d44\u6e90<\/h4>\n<p>&lt;link rel&#061;&#034;stylesheet&#034; href&#061;&#034;\/static\/css\/style.css&#034;&gt;<br \/>\n&lt;script src&#061;&#034;\/static\/script\/jquery-1.7.2.js&#034;&gt;&lt;\/script&gt;<\/p>\n<p>\u6d4f\u89c8\u5668\u4f1a\u00a0\u518d\u53d1 GET \u8bf7\u6c42\u00a0\u62c9 css\/js&#xff0c;\u7531 FileServer \u5904\u7406&#xff0c;\u4e0d\u7ecf\u8fc7\u00a0controller\u3002<\/p>\n<h4>7.5 \u6613\u9519\u70b9<\/h4>\n<table>\n<tr>\u95ee\u9898\u539f\u56e0<\/tr>\n<tbody>\n<tr>\n<td>css 404<\/td>\n<td>go run\u00a0\u5de5\u4f5c\u76ee\u5f55\u4e0d\u5728\u9879\u76ee\u6839&#xff0c;views\/static\u00a0\u627e\u4e0d\u5230<\/td>\n<\/tr>\n<tr>\n<td>\u8def\u5f84\u591a\/\u5c11\u4e00\u5c42<\/td>\n<td>StripPrefix\u00a0\u4e0e\u00a0Handle\u00a0\u524d\u7f00\u4e0d\u4e00\u81f4<\/td>\n<\/tr>\n<tr>\n<td>\u52a8\u6001\u9875\u4e5f\u60f3\u8d70 FileServer<\/td>\n<td>\u5e26\u00a0{{.}}\u00a0\u7684\u6a21\u677f\u5fc5\u987b\u7528\u00a0template.Execute&#xff0c;\u4e0d\u80fd\u5f53\u7eaf\u9759\u6001<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3>\u516b\u3001action \u5982\u4f55\u8fde\u5230 handler&#xff08;\u524d\u540e\u7aef\u95ed\u73af&#xff09;<\/h3>\n<h4>8.1 \u4e09\u6b65\u5bf9\u5e94\u5173\u7cfb<\/h4>\n<p>HTML form action&#061;&#034;\/login&#034;<br \/>\n    \u2195 \u8def\u5f84\u5b57\u7b26\u4e32\u5fc5\u987b\u4e00\u81f4<br \/>\nmain.go  http.HandleFunc(&#034;\/login&#034;, controller.Login)<br \/>\n    \u2195 \u51fd\u6570\u540d<br \/>\ncontroller\/userhandler.go  func Login(w,r) { &#8230; }<\/p>\n<h4>8.2 \u767b\u5f55\u5b8c\u6574\u95ed\u73af<\/h4>\n<p>\u524d\u7aef&#xff08;views\/pages\/user\/login.html&#xff09;&#xff1a;<\/p>\n<p>&lt;form action&#061;&#034;\/login&#034; method&#061;&#034;POST&#034;&gt;<br \/>\n  &lt;input name&#061;&#034;username&#034; &#8230; \/&gt;<br \/>\n  &lt;input name&#061;&#034;password&#034; type&#061;&#034;password&#034; &#8230; \/&gt;<br \/>\n  &lt;input type&#061;&#034;submit&#034; value&#061;&#034;\u767b\u5f55&#034; \/&gt;<br \/>\n&lt;\/form&gt;<\/p>\n<p>\u8def\u7531&#xff08;main.go&#xff09;&#xff1a;<\/p>\n<p>http.HandleFunc(&#034;\/login&#034;, controller.Login)<\/p>\n<p>\u540e\u7aef&#xff08;controller\/userhandler.go&#xff09;&#xff1a;<\/p>\n<p>func Login(w http.ResponseWriter, r *http.Request) {<br \/>\n    username :&#061; r.PostFormValue(&#034;username&#034;)  \/\/ \u5bf9\u5e94 name&#061;&#034;username&#034;<br \/>\n    password :&#061; r.PostFormValue(&#034;password&#034;)  \/\/ \u5bf9\u5e94 name&#061;&#034;password&#034;<br \/>\n    \/\/ &#8230;<br \/>\n}<\/p>\n<h4>8.3 \u5bf9\u5e94\u5173\u7cfb\u8868<\/h4>\n<table>\n<tr>\u524d\u7aef\u540e\u7aef<\/tr>\n<tbody>\n<tr>\n<td>action&#061;&#034;\/login&#034;<\/td>\n<td>HandleFunc(&#034;\/login&#034;, &#8230;)<\/td>\n<\/tr>\n<tr>\n<td>method&#061;&#034;POST&#034;<\/td>\n<td>\u53c2\u6570\u5728 body \u2192\u00a0PostFormValue<\/td>\n<\/tr>\n<tr>\n<td>name&#061;&#034;username&#034;<\/td>\n<td>PostFormValue(&#034;username&#034;)<\/td>\n<\/tr>\n<tr>\n<td>\u70b9\u51fb submit<\/td>\n<td>\u6d4f\u89c8\u5668\u53d1 HTTP POST&#xff0c;\u670d\u52a1\u5668\u8c03\u4e00\u6b21\u00a0Login<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5173\u952e\u6982\u5ff5&#xff1a;\u00a0\u8868\u5355 HTML\u00a0\u4e0d\u662f\u00a0\u8bf7\u6c42\u4f53&#xff1b;\u7528\u6237\u70b9\u63d0\u4ea4\u540e&#xff0c;\u6d4f\u89c8\u5668\u00a0\u6839\u636e\u00a0action\/method\/name\u00a0\u6253\u5305\u00a0\u6210 HTTP \u8bf7\u6c42\u4f53\u3002<\/p>\n<h4>8.4 \u4e0e Ajax \u8def\u5f84\u4e00\u81f4<\/h4>\n<p>$.post(&#034;\/addBook2Cart&#034;, {&#034;bookId&#034;: bookId}, &#8230;);<\/p>\n<p>http.HandleFunc(&#034;\/addBook2Cart&#034;, controller.AddBook2Cart)<\/p>\n<p>\/addBook2Cart\u00a0\u5b57\u7b26\u4e32\u4e09\u5904&#xff08;JS\u3001main\u3001\u6ce8\u91ca&#xff09;\u5fc5\u987b\u4e00\u81f4&#xff0c;\u5dee\u4e00\u4e2a\u5b57\u6bcd\u5c31 404\u3002<\/p>\n<hr \/>\n<h3>\u4e5d\u3001\u5e38\u89c1\u6613\u9519\u70b9<\/h3>\n<table>\n<tr>#\u6613\u9519\u70b9\u540e\u679c\u6b63\u786e\u505a\u6cd5<\/tr>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>HandleFunc(&#034;\/login&#034;, Login())\u00a0\u52a0\u4e86\u62ec\u53f7<\/td>\n<td>\u7f16\u8bd1\u9519\u8bef\u6216\u903b\u8f91\u9519\u4e71<\/td>\n<td>\u4f20\u00a0Login\u00a0\u4e0d\u662f\u00a0Login()<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>\u7528 Form \u5374\u5fd8\u8bb0\u00a0ParseForm<\/td>\n<td>\u7a7a map<\/td>\n<td>\u6216\u7528\u00a0FormValue\u00a0\u81ea\u52a8 Parse<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>\u767b\u5f55\u7528\u00a0FormValue\u00a0\u88ab URL \u53c2\u6570\u6c61\u67d3<\/td>\n<td>\u5b89\u5168\/\u903b\u8f91\u95ee\u9898<\/td>\n<td>\u654f\u611f\u5b57\u6bb5\u7528\u00a0PostFormValue<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td>ListenAndServe\u00a0\u4e0e\u00a0http.Server\u00a0\u6df7\u7528<\/td>\n<td>\u8d85\u65f6\u4e0d\u751f\u6548<\/td>\n<td>\u4e8c\u9009\u4e00&#xff0c;\u914d Server \u5c31\u00a0server.ListenAndServe()<\/td>\n<\/tr>\n<tr>\n<td>5<\/td>\n<td>DefaultServeMux \u4e0e\u81ea\u5b9a\u4e49 mux \u6df7\u6ce8\u518c<\/td>\n<td>\u90e8\u5206\u8def\u7531 404<\/td>\n<td>\u53ea\u7528\u4e00\u4e2a\u8868<\/td>\n<\/tr>\n<tr>\n<td>6<\/td>\n<td>FileServer \u5fd8\u8bb0 StripPrefix<\/td>\n<td>404<\/td>\n<td>\u524d\u7f00\u6210\u5bf9\u5199<\/td>\n<\/tr>\n<tr>\n<td>7<\/td>\n<td>action \u5199\u6210\u00a0\/Login\u00a0\u5927\u5c0f\u5199<\/td>\n<td>404<\/td>\n<td>Go \u8def\u5f84\u5927\u5c0f\u5199\u654f\u611f<\/td>\n<\/tr>\n<tr>\n<td>8<\/td>\n<td>\u5728 Write \u4e4b\u540e SetHeader<\/td>\n<td>\u5934\u65e0\u6548<\/td>\n<td>\u5148 Header \u518d Write<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3>\u5341\u3001Mini FAQ<\/h3>\n<p>Q1&#xff1a;HandleFunc\u00a0\u548c\u00a0Handle\u00a0\u9009\u54ea\u4e2a&#xff1f; A&#xff1a;\u4e1a\u52a1\u903b\u8f91\u7528\u00a0HandleFunc&#xff1b;\u6807\u51c6\u5e93\u63d0\u4f9b\u7684\u00a0FileServer\u00a0\u7b49\u5df2\u662f\u00a0Handler&#xff0c;\u7528\u00a0Handle\u3002<\/p>\n<p>Q2&#xff1a;\u4e3a\u4ec0\u4e48 ListenAndServe \u7b2c\u4e8c\u4e2a\u53c2\u6570\u662f nil&#xff1f; A&#xff1a;nil \u8868\u793a\u4f7f\u7528\u00a0DefaultServeMux&#xff0c;\u4e0e\u524d\u9762\u00a0http.HandleFunc\u00a0\u914d\u5957\u3002<\/p>\n<p>Q3&#xff1a;GET \u548c POST \u53c2\u6570\u90fd\u7528 FormValue \u884c\u5417&#xff1f; A&#xff1a;\u53ef\u4ee5&#xff0c;GET \u7684 query \u548c POST \u7684 body \u90fd\u80fd\u53d6&#xff1b;\u4f46\u767b\u5f55\u5bc6\u7801\u8bf7\u7528\u00a0PostFormValue\u3002<\/p>\n<p>Q4&#xff1a;r.Form[&#034;username&#034;][0]\u00a0\u548c FormValue \u533a\u522b&#xff1f; A&#xff1a;FormValue \u53d6\u7b2c\u4e00\u4e2a&#xff1b;Form \u66b4\u9732\u5168\u90e8\u503c&#xff0c;\u9002\u5408 debug\u3002<\/p>\n<p>Q5&#xff1a;\u5904\u7406\u5668\u91cc\u80fd\u8bfb\u51e0\u6b21 body \u5417&#xff1f; A&#xff1a;body \u662f\u6d41&#xff0c;\u4e00\u822c\u53ea\u80fd\u8bfb\u4e00\u6b21&#xff1b;ParseForm\u00a0\u4f1a\u8bfb\u5e76\u7f13\u5b58\u5230 Form\/PostForm\u3002<\/p>\n<p>Q6&#xff1a;\u7aef\u53e3\u88ab\u5360\u7528\u600e\u4e48\u529e&#xff1f; A&#xff1a;\u6539\u00a0:8080\u00a0\u4e3a\u00a0:8081&#xff0c;\u6216\u5173\u95ed\u5360\u7528 8080 \u7684\u8fdb\u7a0b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#x1f970;\u4e2a\u4eba\u4e3b\u9875&#xff1a;\u4f1a\u7f16\u7a0b\u7684\u571f\u8c46&#xff08;\u6b22\u8fce\u6765\u8bbf&#xff09; &#x1f48e;\u4f5c\u8005\u7b80\u4ecb&#xff1a;\u540e\u7aef\u5b66\u4e60\u8005 \u2744\ufe0f\u4e2a\u4eba\u4e13\u680f&#xff1a;\u6570\u636e\u7ed3\u6784\u4e0e\u7b97\u6cd5&#xff0c;\u6570\u636e\u5e93&#xff0c;leetcode \u2728\u90a3\u4e9b\u4f60\u4e00\u4e2a\u4eba\u8d70\u8fc7\u7684\u591c\u8def&#xff0c;\u7ec8\u5c06\u5316\u4f5c\u7167\u4eae\u672a\u6765\u7684\u5149 \u5bf9\u5e94\u8bfe&#xff1a;\u642d\u5efa\u670d\u52a1\u5668\u3001HTTP \u534f\u8bae\u3001\u5904\u7406\u8bf7\u6c42\u3001\u7ed9\u5ba2\u6237\u7aef\u54cd\u5e94\u3001\u8bfb\u53c2\u6570&#xff08;\u7ea6 5.4 \u8282\u91cd\u70b9&#xff09; \u4ee3\u7801\u793a\u4f8b\u6765\u81ea\u00a0bookstore061<\/p>\n","protected":false},"author":2,"featured_media":91630,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[1680,810],"topic":[],"class_list":["post-91634","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-ios","tag-iphone"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>01. \u642d\u670d\u52a1\u5668\uff1a\u5904\u7406\u5668\u3001\u8def\u7531\u8868\u3001\u8bfb\u8bf7\u6c42\u53c2\u6570\uff08\u7ec6\u8bb2\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/91634.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"01. \u642d\u670d\u52a1\u5668\uff1a\u5904\u7406\u5668\u3001\u8def\u7531\u8868\u3001\u8bfb\u8bf7\u6c42\u53c2\u6570\uff08\u7ec6\u8bb2\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"&#x1f970;\u4e2a\u4eba\u4e3b\u9875&#xff1a;\u4f1a\u7f16\u7a0b\u7684\u571f\u8c46&#xff08;\u6b22\u8fce\u6765\u8bbf&#xff09; &#x1f48e;\u4f5c\u8005\u7b80\u4ecb&#xff1a;\u540e\u7aef\u5b66\u4e60\u8005 \u2744\ufe0f\u4e2a\u4eba\u4e13\u680f&#xff1a;\u6570\u636e\u7ed3\u6784\u4e0e\u7b97\u6cd5&#xff0c;\u6570\u636e\u5e93&#xff0c;leetcode \u2728\u90a3\u4e9b\u4f60\u4e00\u4e2a\u4eba\u8d70\u8fc7\u7684\u591c\u8def&#xff0c;\u7ec8\u5c06\u5316\u4f5c\u7167\u4eae\u672a\u6765\u7684\u5149 \u5bf9\u5e94\u8bfe&#xff1a;\u642d\u5efa\u670d\u52a1\u5668\u3001HTTP \u534f\u8bae\u3001\u5904\u7406\u8bf7\u6c42\u3001\u7ed9\u5ba2\u6237\u7aef\u54cd\u5e94\u3001\u8bfb\u53c2\u6570&#xff08;\u7ea6 5.4 \u8282\u91cd\u70b9&#xff09; \u4ee3\u7801\u793a\u4f8b\u6765\u81ea\u00a0bookstore061\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/91634.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-08T00:08:59+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260808000858-6a76739a86bf2.gif\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/91634.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/91634.html\",\"name\":\"01. \u642d\u670d\u52a1\u5668\uff1a\u5904\u7406\u5668\u3001\u8def\u7531\u8868\u3001\u8bfb\u8bf7\u6c42\u53c2\u6570\uff08\u7ec6\u8bb2\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-08T00:08:59+00:00\",\"dateModified\":\"2026-08-08T00:08:59+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/91634.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/91634.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/91634.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"01. \u642d\u670d\u52a1\u5668\uff1a\u5904\u7406\u5668\u3001\u8def\u7531\u8868\u3001\u8bfb\u8bf7\u6c42\u53c2\u6570\uff08\u7ec6\u8bb2\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"01. \u642d\u670d\u52a1\u5668\uff1a\u5904\u7406\u5668\u3001\u8def\u7531\u8868\u3001\u8bfb\u8bf7\u6c42\u53c2\u6570\uff08\u7ec6\u8bb2\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/91634.html","og_locale":"zh_CN","og_type":"article","og_title":"01. \u642d\u670d\u52a1\u5668\uff1a\u5904\u7406\u5668\u3001\u8def\u7531\u8868\u3001\u8bfb\u8bf7\u6c42\u53c2\u6570\uff08\u7ec6\u8bb2\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"&#x1f970;\u4e2a\u4eba\u4e3b\u9875&#xff1a;\u4f1a\u7f16\u7a0b\u7684\u571f\u8c46&#xff08;\u6b22\u8fce\u6765\u8bbf&#xff09; &#x1f48e;\u4f5c\u8005\u7b80\u4ecb&#xff1a;\u540e\u7aef\u5b66\u4e60\u8005 \u2744\ufe0f\u4e2a\u4eba\u4e13\u680f&#xff1a;\u6570\u636e\u7ed3\u6784\u4e0e\u7b97\u6cd5&#xff0c;\u6570\u636e\u5e93&#xff0c;leetcode \u2728\u90a3\u4e9b\u4f60\u4e00\u4e2a\u4eba\u8d70\u8fc7\u7684\u591c\u8def&#xff0c;\u7ec8\u5c06\u5316\u4f5c\u7167\u4eae\u672a\u6765\u7684\u5149 \u5bf9\u5e94\u8bfe&#xff1a;\u642d\u5efa\u670d\u52a1\u5668\u3001HTTP \u534f\u8bae\u3001\u5904\u7406\u8bf7\u6c42\u3001\u7ed9\u5ba2\u6237\u7aef\u54cd\u5e94\u3001\u8bfb\u53c2\u6570&#xff08;\u7ea6 5.4 \u8282\u91cd\u70b9&#xff09; \u4ee3\u7801\u793a\u4f8b\u6765\u81ea\u00a0bookstore061","og_url":"https:\/\/www.wsisp.com\/helps\/91634.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-08T00:08:59+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260808000858-6a76739a86bf2.gif"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"7 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/91634.html","url":"https:\/\/www.wsisp.com\/helps\/91634.html","name":"01. \u642d\u670d\u52a1\u5668\uff1a\u5904\u7406\u5668\u3001\u8def\u7531\u8868\u3001\u8bfb\u8bf7\u6c42\u53c2\u6570\uff08\u7ec6\u8bb2\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-08T00:08:59+00:00","dateModified":"2026-08-08T00:08:59+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/91634.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/91634.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/91634.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"01. \u642d\u670d\u52a1\u5668\uff1a\u5904\u7406\u5668\u3001\u8def\u7531\u8868\u3001\u8bfb\u8bf7\u6c42\u53c2\u6570\uff08\u7ec6\u8bb2\uff09"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/91634","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=91634"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/91634\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/91630"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=91634"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=91634"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=91634"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=91634"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}