Allow to specify response headers (needed for redirecting clients) (#9170)

* Allow to specify response headers (needed for redirecting clients) (#8148)

Co-authored-by: Bernardo Pastorelli <13519917+randomswdev@users.noreply.github.com>

* add addResponseHeaders option

* enable addResponseHeaders

* fix comma

Co-authored-by: randomswdev <randomswdev@users.noreply.github.com>
Co-authored-by: Bernardo Pastorelli <13519917+randomswdev@users.noreply.github.com>
This commit is contained in:
William Cheng
2021-04-05 16:27:41 +08:00
committed by GitHub
parent 226a8b5f77
commit c79d056935
13 changed files with 113 additions and 48 deletions

View File

@@ -56,7 +56,7 @@ func NewRouter(routers ...Router) *mux.Router {
}
// EncodeJSONResponse uses the json encoder to write an interface to the http response with an optional status code
func EncodeJSONResponse(i interface{}, status *int, w http.ResponseWriter) error {
func EncodeJSONResponse(i interface{}, status *int, headers map[string][]string, w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
if status != nil {
w.WriteHeader(*status)