Implementing this method allows for more control over requests from the backend then GetFile().
More details of the request are available from the request object which allows access to URL, method, postdata and headers.
A response can be send via the response object. The response does not have to be finished from this method and it's possible to be finished asynchronously via wxWebViewHandlerResponse::Finish().
wxSharedPtr<wxWebViewHandlerResponse> response) override
{
response->SetHeader("Access-Control-Allow-Origin", "*");
response->SetHeader("Access-Control-Allow-Headers", "*");
{
response->Finish("");
return;
}
{
response->FinishWithError();
return;
}
...
response->SetContentType("application/json");
response->Finish("{ result: true }");
}
String class for passing textual data to or receiving it from wxWidgets.
Definition: string.h:372
bool StartsWith(const wxString &prefix, wxString *rest=nullptr) const
This function can be used to test if the string starts with the specified prefix.
bool IsSameAs(const wxString &s, bool caseSensitive=true) const
Test whether the string is equal to another string s.
virtual void StartRequest(const wxWebViewHandlerRequest &request, wxSharedPtr< wxWebViewHandlerResponse > response)
Implementing this method allows for more control over requests from the backend then GetFile().
A class giving access to various parameters of a webview request.
Definition: webview.h:390
virtual wxString GetDataString(const wxMBConv &conv=wxConvUTF8) const
virtual wxString GetHeader(const wxString &name) const =0
Returns a header from the request or an empty string if the header could not be found.
virtual wxString GetMethod() const =0