aboutsummaryrefslogtreecommitdiff
path: root/zenserver/testing/httptest.cpp
blob: 653f7604623d7dc05e395c659b3ede067c96906a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright Epic Games, Inc. All Rights Reserved.

#include "httptest.h"

namespace zen {

HttpTestingService::HttpTestingService()
{
	m_Router.RegisterRoute(
		"hello",
		[this](HttpRouterRequest& Req) { Req.ServerRequest().WriteResponse(HttpResponseCode::OK); },
		HttpVerb::kGet);

	m_Router.RegisterRoute(
		"echo",
		[this](HttpRouterRequest& Req) {
			IoBuffer Body = Req.ServerRequest().ReadPayload();
			Req.ServerRequest().WriteResponse(HttpResponseCode::OK, HttpContentType::kBinary, Body);
		},
		HttpVerb::kPost);
}

HttpTestingService::~HttpTestingService()
{
}

const char*
HttpTestingService::BaseUri() const
{
	return "/testing/";
}

void
HttpTestingService::HandleRequest(HttpServerRequest& Request)
{
	m_Router.HandleRequest(Request);
}

}  // namespace zen