Skip to content

Commit

Permalink
update server.Stat
Browse files Browse the repository at this point in the history
  • Loading branch information
luopengift committed Apr 23, 2024
1 parent 614228e commit f3cf68d
Show file tree
Hide file tree
Showing 16 changed files with 21 additions and 252 deletions.
5 changes: 0 additions & 5 deletions .idea/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions .idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

9 changes: 0 additions & 9 deletions .idea/requests.iml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
### Quick Start
#### Get Started
```shell
cat examples/example_1/main.go
cat github.com/golang-io/examples/example_1/main.go
```

```go
Expand All @@ -44,7 +44,7 @@ func main() {
```

```shell
$ go run examples/example_1/main.go
$ go run github.com/golang-io/examples/example_1/main.go
* Connect: httpbin.org:80
* Got Conn: <nil> -> <nil>
* Connect: httpbin.org:443
Expand Down Expand Up @@ -112,7 +112,7 @@ func main() {
```
```shell
% go run examples/example_2/main.go
% go run github.com/golang-io/examples/example_2/main.go
2024/03/22 20:31:12 {
"args": {},
"headers": {
Expand Down Expand Up @@ -153,7 +153,7 @@ func main() {

```
```shell
% go run examples/example_3/main.go
% go run github.com/golang-io/examples/example_3/main.go
2024/03/22 20:43:25 resp={
"args": {},
"data": "Hello world",
Expand Down Expand Up @@ -285,7 +285,7 @@ pong
```
And, there are some logs from server.
```shell
% go run examples/server/example_1/main.go
% go run github.com/golang-io/examples/server/example_1/main.go
2024-03-27 02:47:47 http serve 0.0.0.0:1234
2024/03/27 02:47:59 "GET http://127.0.0.1:1234/echo HTTP/1.1" from 127.0.0.1:60922 - 000 0B in 9.208µs
path use {}
Expand Down
11 changes: 0 additions & 11 deletions examples/example_1/main.go

This file was deleted.

20 changes: 0 additions & 20 deletions examples/example_2/main.go

This file was deleted.

13 changes: 0 additions & 13 deletions examples/example_3/main.go

This file was deleted.

13 changes: 0 additions & 13 deletions examples/server/example_1/go.mod

This file was deleted.

6 changes: 0 additions & 6 deletions examples/server/example_1/go.sum

This file was deleted.

72 changes: 0 additions & 72 deletions examples/server/example_1/main.go

This file was deleted.

7 changes: 0 additions & 7 deletions examples/websocket/client/go.mod

This file was deleted.

4 changes: 0 additions & 4 deletions examples/websocket/client/go.sum

This file was deleted.

64 changes: 0 additions & 64 deletions examples/websocket/client/main.go

This file was deleted.

21 changes: 16 additions & 5 deletions stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,32 @@ import (
)

const RequestId = "Request-Id"
const dateTime = "2006-01-02 15:04:05.000"

// Stat stats
type Stat struct {
RequestId string
RequestId string `json:"RequestId"`
StartAt string `json:"StartAt"`
Cost int64 `json:"Cost"`
Request struct {

Request struct {
// Remote is remote addr in server side,
// For client requests, it is unused.
Remote string `json:"Remote"`

// URL is Request.URL
// For client requests, is request addr. contains schema://ip:port/path/xx
// For server requests, is only path. eg: /api/v1/xxx
URL string `json:"URL"`
Method string `json:"Method"`
Header map[string]string `json:"Header"`
URL string `json:"URL"`
Body any `json:"Body"`
} `json:"Request"`
Response struct {

// URL is server addr(http://127.0.0.1:8080).
// For client requests, it is unused.
URL string `json:"URL"`
Header map[string]string `json:"Header"`
Body any `json:"Body"`
StatusCode int `json:"StatusCode"`
Expand All @@ -33,8 +46,6 @@ func (stat *Stat) String() string {
return string(b)
}

const dateTime = "2006-01-02 15:04:05.000"

// StatLoad stat.
func StatLoad(resp *Response) *Stat {
stat := &Stat{
Expand Down

0 comments on commit f3cf68d

Please sign in to comment.