Skip to content

Commit 48ade6b

Browse files
committed
Add new func that processes the request and returns the nonce
1 parent f216236 commit 48ade6b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

secure.go

+9
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,15 @@ func (s *Secure) Process(w http.ResponseWriter, r *http.Request) error {
238238
return err
239239
}
240240

241+
// ProcessAndReturnNonce runs the actual checks and writes the headers in the ResponseWriter.
242+
// In addition, the generated nonce for the request is returned as well as the error value.
243+
func (s *Secure) ProcessAndReturnNonce(w http.ResponseWriter, r *http.Request) (string, error) {
244+
responseHeader, newR, err := s.processRequest(w, r)
245+
addResponseHeaders(responseHeader, w)
246+
247+
return CSPNonce(newR.Context()), err
248+
}
249+
241250
// ProcessNoModifyRequest runs the actual checks but does not write the headers in the ResponseWriter.
242251
func (s *Secure) ProcessNoModifyRequest(w http.ResponseWriter, r *http.Request) (http.Header, *http.Request, error) {
243252
return s.processRequest(w, r)

0 commit comments

Comments
 (0)