func helloHandler(w web.ResponseWriter, r *web.Request) { w.WriteHeader(http.StatusUnauthorized) fmt.Fprint(w, "Unauthorized access detected!") }
func helloHandler(w web.ResponseWriter, r *web.Request) { w.Header().Set("Content-Type", "application/json") fmt.Fprint(w, `{"message": "Hello, World!"}`) }In this example, the helloHandler function sets a custom response header "Content-Type" to "application/json" using the Set() method of the ResponseWriter's Header object. Both of these code examples use the ResponseWriter and WriteHeader() method from the github.com/gocraft/web package library.