github.com/machinefi/w3bstream@v1.6.5-rc9.0.20240426031326-b8c7c4876e72/pkg/depends/kit/httptransport/mock/mock_response_writer_test.go (about)

     1  package mock
     2  
     3  import (
     4  	"fmt"
     5  	"net/http"
     6  )
     7  
     8  func ExampleResponseWriter() {
     9  	rw := NewMockResponseWriter()
    10  	rw.Header().Set("Content-Type", "application/json")
    11  
    12  	rw.WriteHeader(http.StatusOK)
    13  	rw.Write([]byte(`{"status":"ok"}`))
    14  
    15  	fmt.Println(string(rw.MustDumpResponse()))
    16  	// Output:
    17  	// HTTP/0.0 200 OK
    18  	// Content-Type: application/json
    19  	//
    20  	// {"status":"ok"}
    21  }