-
Notifications
You must be signed in to change notification settings - Fork 127
/
lesson6.slide
85 lines (48 loc) · 1.43 KB
/
lesson6.slide
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
HTTP & Friends
Lesson 6
30 May 2024
Tags: golang, go
Ivan Nečas <[email protected]>
Red Hat, Inc.
https://github.com/RedHatOfficial/GoCourse
@RedHat
* Sources
- [[https://github.com/RedHatOfficial/GoCourse]]
.image ./common/qr_address.png
* Web services in Go
- one of he most common thing written in go these days
- largery used in http-based microservices
- rich support for HTTP-related directly [[https://golang.org/pkg/net/http/][in the language]] (batteries included)
* Basic web server
.play lesson6/web_server.go
* Basic web server
- a global `http.DefaultServerMux` is used for registering handlers
* Web server with more control
.play lesson6/web_server_more_control.go /^func main/,/^}/
* Multiple paths
.play lesson6/web_server_multi.go
* Multiple paths
- the longest prefix always wins
* Inspecting requests (cool trick)
.play lesson6/web_server_inspect.go
* Parsing requests: query
.play lesson6/web_server_params.go
* Parsing requests: raw body
.play lesson6/web_server_body.go
* Parsing requests: json
.play lesson6/web_server_json.go
* Parsing requests: json (2)
.play lesson6/web_server_json_2.go
* Headers and status codes
.play lesson6/web_server_headers.go
* Status codes (2)
.play lesson6/web_server_status_codes.go
* Client
.play lesson6/client.go
* Client (post)
.play lesson6/client_post.go /// Params/,/End OMIT/
* Proxy
.play lesson6/proxy.go
* Metrics
.play lesson6/metrics.go