response.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package entry
  2. import "net/http"
  3. // Response is the cached response will be send to the clients
  4. // its fields setted at runtime on each of the non-cached executions
  5. // non-cached executions = first execution, and each time after
  6. // cache expiration datetime passed.
  7. type Response struct {
  8. // statusCode for the response cache handler.
  9. statusCode int
  10. // body is the contents will be served by the cache handler.
  11. body []byte
  12. // the total headers of the response, including content type.
  13. headers http.Header
  14. }
  15. // StatusCode returns a valid status code.
  16. func (r *Response) StatusCode() int {
  17. if r.statusCode <= 0 {
  18. r.statusCode = 200
  19. }
  20. return r.statusCode
  21. }
  22. // ContentType returns a valid content type
  23. // func (r *Response) ContentType() string {
  24. // if r.headers == "" {
  25. // r.contentType = "text/html; charset=utf-8"
  26. // }
  27. // return r.contentType
  28. // }
  29. // Headers returns the total headers of the cached response.
  30. func (r *Response) Headers() http.Header {
  31. return r.headers
  32. }
  33. // Body returns contents will be served by the cache handler.
  34. func (r *Response) Body() []byte {
  35. return r.body
  36. }