Skip to content

Commit 627a1b2

Browse files
committed
chore: Http -> HTTP
1 parent 74b55a0 commit 627a1b2

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

middleware.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func (w *wrappedResponseWriter) Write(b []byte) (int, error) {
159159
return n, err
160160
}
161161

162-
type HttpRequest struct {
162+
type HTTPRequest struct {
163163
RequestMethod string `json:"requestMethod"`
164164
RequestUrl string `json:"requestUrl"`
165165
RequestSize string `json:"requestSize"`
@@ -176,20 +176,20 @@ type HttpRequest struct {
176176
Protocol string `json:"protocol"`
177177
}
178178

179-
type HttpRequestLog struct {
179+
type HTTPRequestLog struct {
180180
Time string `json:"time"`
181181
Trace string `json:"logging.googleapis.com/trace"`
182182
Severity string `json:"severity"`
183-
HttpRequest HttpRequest `json:"httpRequest"`
183+
HTTPRequest HTTPRequest `json:"httpRequest"`
184184
AdditionalData AdditionalData `json:"data,omitempty"`
185185
}
186186

187187
func writeRequestLog(r *http.Request, config *Config, status int, responseSize int, elapsed time.Duration, trace string, severity Severity) error {
188-
requestLog := &HttpRequestLog{
188+
requestLog := &HTTPRequestLog{
189189
Time: time.Now().Format(time.RFC3339Nano),
190190
Trace: trace,
191191
Severity: severity.String(),
192-
HttpRequest: HttpRequest{
192+
HTTPRequest: HTTPRequest{
193193
RequestMethod: r.Method,
194194
RequestUrl: r.URL.RequestURI(),
195195
RequestSize: fmt.Sprintf("%d", r.ContentLength),

stackdriver_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,23 @@ func TestIntegration(t *testing.T) {
4444
handler.ServeHTTP(w, r)
4545

4646
// check request log
47-
var httpRequestLog HttpRequestLog
47+
var httpRequestLog HTTPRequestLog
4848
err := json.Unmarshal(requestLogOut.Bytes(), &httpRequestLog)
4949
if err != nil {
5050
t.Fatal(err)
5151
}
5252

5353
opts := []cmp.Option{
54-
cmpopts.IgnoreFields(HttpRequestLog{}, "Time", "Trace"),
55-
cmpopts.IgnoreFields(HttpRequest{}, "RemoteIp", "ServerIp", "Latency"),
54+
cmpopts.IgnoreFields(HTTPRequestLog{}, "Time", "Trace"),
55+
cmpopts.IgnoreFields(HTTPRequest{}, "RemoteIp", "ServerIp", "Latency"),
5656
}
57-
expected := HttpRequestLog{
57+
expected := HTTPRequestLog{
5858
Severity: "ERROR",
5959
AdditionalData: AdditionalData{
6060
"service": "foo",
6161
"version": 1.0,
6262
},
63-
HttpRequest: HttpRequest{
63+
HTTPRequest: HTTPRequest{
6464
RequestMethod: "GET",
6565
RequestUrl: "/foo?bar=baz",
6666
RequestSize: "0",
@@ -79,8 +79,8 @@ func TestIntegration(t *testing.T) {
7979
t.Errorf("diff: %s", cmp.Diff(httpRequestLog, expected, opts...))
8080
}
8181

82-
if !strings.HasSuffix(httpRequestLog.HttpRequest.Latency, "s") {
83-
t.Errorf("invalid latency: %s", httpRequestLog.HttpRequest.Latency)
82+
if !strings.HasSuffix(httpRequestLog.HTTPRequest.Latency, "s") {
83+
t.Errorf("invalid latency: %s", httpRequestLog.HTTPRequest.Latency)
8484
}
8585

8686
// check context log
@@ -141,20 +141,20 @@ func TestNoContextLog(t *testing.T) {
141141
handler.ServeHTTP(w, r)
142142

143143
// check request log
144-
var httpRequestLog HttpRequestLog
144+
var httpRequestLog HTTPRequestLog
145145
err := json.Unmarshal(requestLogOut.Bytes(), &httpRequestLog)
146146
if err != nil {
147147
t.Fatal(err)
148148
}
149149

150150
opts := []cmp.Option{
151-
cmpopts.IgnoreFields(HttpRequestLog{}, "Time", "Trace"),
152-
cmpopts.IgnoreFields(HttpRequest{}, "RemoteIp", "ServerIp", "Latency"),
151+
cmpopts.IgnoreFields(HTTPRequestLog{}, "Time", "Trace"),
152+
cmpopts.IgnoreFields(HTTPRequest{}, "RemoteIp", "ServerIp", "Latency"),
153153
}
154-
expected := HttpRequestLog{
154+
expected := HTTPRequestLog{
155155
Severity: "DEFAULT",
156156
AdditionalData: nil,
157-
HttpRequest: HttpRequest{
157+
HTTPRequest: HTTPRequest{
158158
RequestMethod: "GET",
159159
RequestUrl: "/foo?bar=baz",
160160
RequestSize: "0",

0 commit comments

Comments
 (0)