Fix auth example.

This commit is contained in:
Nathan Osman
2017-08-05 11:35:57 -07:00
parent c0c7d88366
commit ad01f31cf2
2 changed files with 14 additions and 4 deletions

View File

@@ -28,12 +28,19 @@
#include <qhttpengine/localauthmiddleware.h>
#include <qhttpengine/qobjecthandler.h>
#include <qhttpengine/server.h>
#include <qhttpengine/socket.h>
int main(int argc, char * argv[])
{
QCoreApplication a(argc, argv);
QHttpEngine::QObjectHandler handler;
handler.registerMethod("", [](QHttpEngine::Socket *socket) {
socket->setStatusCode(QHttpEngine::Socket::OK);
socket->writeHeaders();
socket->close();
});
QHttpEngine::Server server(&handler);
if (!server.listen(QHostAddress::LocalHost)) {
qCritical("unable to bind to a local port");