func handler(w http.ResponseWriter, r *http.Request) { // delete the "Content-Type" header r.Header.Del("Content-Type") // process the request // ... }
w.Header().Set("Access-Control-Allow-Origin", "*") w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization") w.Header().Del("Access-Control-Allow-Methods")In this example, headers related to Cross-Origin Resource Sharing (CORS) are set for the HTTP response. The "Access-Control-Allow-Methods" header is later deleted for security reasons as it can allow attackers to perform unwanted actions. The net/http package is the library package used in these code examples.