Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

35 rindas
640B

  1. package main
  2. import (
  3. "encoding/json"
  4. "net/http"
  5. )
  6. type errorHTTPResponse struct {
  7. ErrorMsg string
  8. HTTPStatusCode int
  9. HTTPHeader http.Header
  10. }
  11. func (e errorHTTPResponse) Error() string {
  12. return e.ErrorMsg
  13. }
  14. func errorHTTPResponseNew(r *http.Response, msg string) (e errorHTTPResponse) {
  15. e.ErrorMsg = msg
  16. e.HTTPStatusCode = r.StatusCode
  17. e.HTTPHeader = r.Header
  18. return e
  19. }
  20. type crmdReason struct {
  21. Reason string `json:"reason"`
  22. Data string `json:"data"`
  23. }
  24. func (e *errorHTTPResponse) XStatusReason() (r crmdReason) {
  25. jsonStr := e.HTTPHeader.Get("X-Status-Reason")
  26. json.Unmarshal([]byte(jsonStr), &r)
  27. return
  28. }