Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rez1dent3 committed Apr 12, 2024
1 parent ffd3fc9 commit 4355319
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
4 changes: 3 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
deployments
.git
docs
node_modules
deployments
.github
*.pb.go
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/google/uuid v1.6.0
github.com/gorilla/handlers v1.5.2
github.com/gorilla/mux v1.8.1
github.com/gripmock/stuber v0.0.0-20240411211057-abb2f3d06dcb
github.com/gripmock/stuber v0.0.0-20240412102748-e33bea496d15
github.com/jhump/protoreflect v1.16.0
github.com/joho/godotenv v1.5.1
github.com/kelseyhightower/envconfig v1.4.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
github.com/gripmock/deeply v1.0.7 h1:qYLBu8/x9xq0kvHV5UG/SIP9M23T11jkcUgzhn1xGIU=
github.com/gripmock/deeply v1.0.7/go.mod h1:xKJ9we/cU0CnCoYa+En2MirViTzvgsNp5B0hya1DhKk=
github.com/gripmock/stuber v0.0.0-20240411211057-abb2f3d06dcb h1:2ZQE4VegnSudNAn0YzdF6AH4GJSv6kSdKqMg/R6l5NM=
github.com/gripmock/stuber v0.0.0-20240411211057-abb2f3d06dcb/go.mod h1:CrbeiDxvJX1xsrUwcEVhCmNz4CQPq0z7RfXLIHOgsn0=
github.com/gripmock/stuber v0.0.0-20240412102748-e33bea496d15 h1:7VlvlnhZpKiEaE9EOu/QPCxoAkvQ8Plje+pLlMuIECw=
github.com/gripmock/stuber v0.0.0-20240412102748-e33bea496d15/go.mod h1:CrbeiDxvJX1xsrUwcEVhCmNz4CQPq0z7RfXLIHOgsn0=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM=
github.com/jhump/protoreflect v1.16.0 h1:54fZg+49widqXYQ0b+usAFHbMkBGR4PpXrsHc8+TBDg=
Expand Down
7 changes: 7 additions & 0 deletions internal/pkg/muxmiddleware/logger.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package muxmiddleware

import (
"bytes"
"io"
"net/http"
"time"

Expand All @@ -14,6 +16,10 @@ func RequestLogger(next http.Handler) http.Handler {
ip, err := getIP(r)
now := time.Now()

bodyBytes, _ := io.ReadAll(r.Body)
r.Body.Close() // must close
r.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))

next.ServeHTTP(ww, r)

logger.
Expand All @@ -22,6 +28,7 @@ func RequestLogger(next http.Handler) http.Handler {
IPAddr("ip", ip).
Str("method", r.Method).
Str("url", r.URL.RequestURI()).
RawJSON("input", bodyBytes).
Dur("elapsed", time.Since(now)).
Str("ua", r.UserAgent()).
Int("bytes", ww.bytes).
Expand Down
11 changes: 0 additions & 11 deletions protoc-gen-gripmock/server.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -186,17 +186,6 @@ func (s *{{.ServiceName}}) {{.Name}}(srv {{.SvcPackage}}{{.ServiceName}}_{{.Name
{{ end }}

{{ define "find_stub" }}
type payload struct {
Service string `json:"service"`
Method string `json:"method"`
Data interface{} `json:"data"`
}

type response struct {
Data interface{} `json:"data"`
Error string `json:"error"`
}

func findStub(ctx context.Context, service, method string, md metadata.MD, in, out protoreflect.ProtoMessage) error {
api, err := sdk.NewClientWithResponses(fmt.Sprintf("http://localhost%s/api", HTTP_PORT),
sdk.WithHTTPClient(http.DefaultClient),
Expand Down

0 comments on commit 4355319

Please sign in to comment.