Skip to content

Latest commit

 

History

History
39 lines (27 loc) · 583 Bytes

tutorial.md

File metadata and controls

39 lines (27 loc) · 583 Bytes

net/http

1.

  • 请求参数
  • 请求方法
  • 响应信息

2.

启动服务的三种方式:

2.1

func Name (w *http.ResponseWrite, r http.Request) {}
http.HandleFunc("/", Name)
http.ListenAndServe

2.2

- type Product struct
- func (p Product) List(w *http.ResponseWrite, r http.Request)
- http.ListenAndServe(":9090", Product)

2.3

- type Product struct
- func(p Product) List(w *http.ResponseWrite, r http.Request)
- server := http.NewServeMux()
- http.HandleFunc("/", p.List)
- http.ListenAndServe(":1234", server)