MCPcopy Create free account
hub / github.com/Tracktion/choc / handleResourceRequest

Method handleResourceRequest

examples/webview_desktop_app.cpp:141–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

139 }
140
141 choc::ui::WebView::Options::Resource handleResourceRequest (const std::string& path)
142 {
143 choc::ui::WebView::Options::Resource resource;
144
145 if (path == "/" || path == "/index.html")
146 {
147 auto html = getMainHTML();
148 resource.data = std::vector<uint8_t>(html.begin(), html.end());
149 resource.mimeType = "text/html";
150 }
151 else if (path == "/style.css")
152 {
153 auto css = getCSS();
154 resource.data = std::vector<uint8_t>(css.begin(), css.end());
155 resource.mimeType = "text/css";
156 }
157 else if (path == "/script.js")
158 {
159 auto js = getJavaScript();
160 resource.data = std::vector<uint8_t>(js.begin(), js.end());
161 resource.mimeType = "application/javascript";
162 }
163
164 return resource;
165 }
166
167 void loadInitialContent()
168 {

Callers 1

setupWebViewMethod · 0.95

Calls 2

beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected