Skip to content

Commit

Permalink
feat: added caching and security middlewares
Browse files Browse the repository at this point in the history
  • Loading branch information
hokamsingh committed Aug 26, 2024
1 parent 9f27c43 commit d1c9ff0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion internal/core/middleware/json_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ func NewJsonParser(options ParserOptions) *JSONParser {
}
}

type JsonKey string

func (jp *JSONParser) Handle(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Header.Get("Content-Type") == "application/json" {
Expand All @@ -70,7 +72,7 @@ func (jp *JSONParser) Handle(next http.Handler) http.Handler {
}

// Store the parsed JSON in the context
key := "jsonBody"
key := JsonKey("jsonBody")
r = r.WithContext(context.WithValue(r.Context(), key, body))
}
next.ServeHTTP(w, r)
Expand Down

0 comments on commit d1c9ff0

Please sign in to comment.