| 28 | namespace cripts::Bundle |
| 29 | { |
| 30 | class Caching : public cripts::Bundle::Base |
| 31 | { |
| 32 | using super_type = cripts::Bundle::Base; |
| 33 | using self_type = Caching; |
| 34 | |
| 35 | public: |
| 36 | using super_type::Base; |
| 37 | |
| 38 | // This is the factory to create an instance of this bundle |
| 39 | static self_type & |
| 40 | _activate(cripts::Instance &inst) |
| 41 | { |
| 42 | auto *entry = new self_type(); |
| 43 | |
| 44 | inst.AddBundle(entry); |
| 45 | |
| 46 | return *entry; |
| 47 | } |
| 48 | |
| 49 | [[nodiscard]] const cripts::string & |
| 50 | Name() const override |
| 51 | { |
| 52 | return _name; |
| 53 | } |
| 54 | |
| 55 | self_type & |
| 56 | cache_control(cripts::string_view cc, bool force = false) |
| 57 | { |
| 58 | NeedCallback(cripts::Callbacks::DO_READ_RESPONSE); |
| 59 | _cc = cc; |
| 60 | _force_cc = force; |
| 61 | |
| 62 | return *this; |
| 63 | } |
| 64 | |
| 65 | self_type & |
| 66 | disable(bool disable = true) |
| 67 | { |
| 68 | NeedCallback(cripts::Callbacks::DO_REMAP); |
| 69 | _disabled = disable; |
| 70 | |
| 71 | return *this; |
| 72 | } |
| 73 | |
| 74 | void doReadResponse(cripts::Context *context) override; |
| 75 | void doRemap(cripts::Context *context) override; |
| 76 | |
| 77 | private: |
| 78 | static const cripts::string _name; |
| 79 | cripts::string _cc = ""; |
| 80 | bool _force_cc = false; |
| 81 | bool _disabled = false; |
| 82 | }; |
| 83 | |
| 84 | } // namespace cripts::Bundle |