directives.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. package httpcc
  2. type RequestDirective struct {
  3. maxAge *uint64
  4. maxStale *uint64
  5. minFresh *uint64
  6. noCache bool
  7. noStore bool
  8. noTransform bool
  9. onlyIfCached bool
  10. extensions map[string]string
  11. }
  12. func (d *RequestDirective) MaxAge() (uint64, bool) {
  13. if v := d.maxAge; v != nil {
  14. return *v, true
  15. }
  16. return 0, false
  17. }
  18. func (d *RequestDirective) MaxStale() (uint64, bool) {
  19. if v := d.maxStale; v != nil {
  20. return *v, true
  21. }
  22. return 0, false
  23. }
  24. func (d *RequestDirective) MinFresh() (uint64, bool) {
  25. if v := d.minFresh; v != nil {
  26. return *v, true
  27. }
  28. return 0, false
  29. }
  30. func (d *RequestDirective) NoCache() bool {
  31. return d.noCache
  32. }
  33. func (d *RequestDirective) NoStore() bool {
  34. return d.noStore
  35. }
  36. func (d *RequestDirective) NoTransform() bool {
  37. return d.noTransform
  38. }
  39. func (d *RequestDirective) OnlyIfCached() bool {
  40. return d.onlyIfCached
  41. }
  42. func (d *RequestDirective) Extensions() map[string]string {
  43. return d.extensions
  44. }
  45. func (d *RequestDirective) Extension(s string) string {
  46. return d.extensions[s]
  47. }
  48. type ResponseDirective struct {
  49. maxAge *uint64
  50. noCache []string
  51. noStore bool
  52. noTransform bool
  53. public bool
  54. private []string
  55. proxyRevalidate bool
  56. sMaxAge *uint64
  57. extensions map[string]string
  58. }
  59. func (d *ResponseDirective) MaxAge() (uint64, bool) {
  60. if v := d.maxAge; v != nil {
  61. return *v, true
  62. }
  63. return 0, false
  64. }
  65. func (d *ResponseDirective) NoCache() []string {
  66. return d.noCache
  67. }
  68. func (d *ResponseDirective) NoStore() bool {
  69. return d.noStore
  70. }
  71. func (d *ResponseDirective) NoTransform() bool {
  72. return d.noTransform
  73. }
  74. func (d *ResponseDirective) Public() bool {
  75. return d.public
  76. }
  77. func (d *ResponseDirective) Private() []string {
  78. return d.private
  79. }
  80. func (d *ResponseDirective) ProxyRevalidate() bool {
  81. return d.proxyRevalidate
  82. }
  83. func (d *ResponseDirective) SMaxAge() (uint64, bool) {
  84. if v := d.sMaxAge; v != nil {
  85. return *v, true
  86. }
  87. return 0, false
  88. }
  89. func (d *ResponseDirective) Extensions() map[string]string {
  90. return d.extensions
  91. }
  92. func (d *ResponseDirective) Extension(s string) string {
  93. return d.extensions[s]
  94. }