This guide demonstrates the basics of creating a C++ web service that processes incoming HTTP requests.
HelloWebWorld and click the Add button.
#pragma once
#include "tef/Tentity.h"
class HelloWebWorld : public tef::RequestHandler
{
public:
HelloWebWorld();
virtual ~HelloWebWorld();
virtual const char* Path() const override;
virtual void Process(tef::RequestContext& context) const override;
};
HelloWebWorld and click the Add button.
#include "stdafx.h"
#include "HelloWebWorld.h"
static HelloWebWorld Instance;
HelloWebWorld::HelloWebWorld()
{
tef::Register(this);
}
HelloWebWorld::~HelloWebWorld()
{
}
const char* HelloWebWorld::Path() const
{
return "/helloworld";
}
void HelloWebWorld::Process(tef::RequestContext& context) const
{
tef::JsonOutput<128> json(context.Output);
json.startObject();
json.writeStringProperty(L"Message", L"Hello World!");
json.endObject();
}
default.app) is set listening to port 42580 which must be registered on the first run:
addurl.bat file in the tef_sdk directory.addurl.bat fileaddurl.bat file with the administrator privileges.default.app is a text file:
[address]
http://+:42580/
[address] |
: the syntax is explained here. |
tefsvr.exe.http://127.0.0.1:42580/helloworld. The following image depicts the output: