golang web programming

net/http包

  • ServeMux when resolving URL, if the URL handlers not end with a /, we need an exact match will call the corresponding handler
    • If / and / hello URL corresponding to two processors exist, when we pass /hello/there, the call is / processor
    • The / hello processor read / hello / above example the call processor / hello / processor
  • http.Request
// r是 *http.Request 类型

// 得到的是字符串切片
h := r.Header["Accept-Encoding"]

// 得到的是一整个字符串
h := r.Header.Get("Accept-Encoding")

// r.Body是一个io.ReadCloser接口,也就是包含Reader和Closer两接口
  • FromValue method will automatically call ParseForm method or ParseMultipartForm
    • A value of the first method only by the given key
    • You want to get all the values ​​require direct access Form structure
Published 161 original articles · won praise 19 · views 50000 +

Guess you like

Origin blog.csdn.net/winter_wu_1998/article/details/101670224