packagematchersimport("fmt""net/http""net/http/httptest""github.com/onsi/gomega/format")typeHaveHTTPStatusMatcherstruct{Expectedinterface{}}func(matcher*HaveHTTPStatusMatcher)Match(actualinterface{})(successbool,errerror){varresp*http.Responseswitcha:=actual.(type){case*http.Response:resp=acase*httptest.ResponseRecorder:resp=a.Result()default:returnfalse,fmt.Errorf("HaveHTTPStatus matcher expects *http.Response or *httptest.ResponseRecorder. Got:\n%s",format.Object(actual,1))}switche:=matcher.Expected.(type){caseint:returnresp.StatusCode==e,nilcasestring:returnresp.Status==e,nil}returnfalse,fmt.Errorf("HaveHTTPStatus matcher must be passed an int or a string. Got:\n%s",format.Object(matcher.Expected,1))}func(matcher*HaveHTTPStatusMatcher)FailureMessage(actualinterface{})(messagestring){returnformat.Message(actual,"to have HTTP status",matcher.Expected)}func(matcher*HaveHTTPStatusMatcher)NegatedFailureMessage(actualinterface{})(messagestring){returnformat.Message(actual,"not to have HTTP status",matcher.Expected)}