mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-02 02:51:42 +00:00
SCRIPT namespace replacements
This commit is contained in:
committed by
Peter Johnson
parent
ae6c043632
commit
9aca8e0fd6
@@ -12,9 +12,9 @@
|
||||
#include "wpi/net/uv/Tcp.hpp"
|
||||
#include "wpi/util/print.hpp"
|
||||
|
||||
namespace uv = wpi::uv;
|
||||
namespace uv = wpi::net::uv;
|
||||
|
||||
class MyHttpServerConnection : public wpi::HttpServerConnection {
|
||||
class MyHttpServerConnection : public wpi::net::HttpServerConnection {
|
||||
public:
|
||||
explicit MyHttpServerConnection(std::shared_ptr<uv::Stream> stream)
|
||||
: HttpServerConnection(stream) {}
|
||||
@@ -24,9 +24,9 @@ class MyHttpServerConnection : public wpi::HttpServerConnection {
|
||||
};
|
||||
|
||||
void MyHttpServerConnection::ProcessRequest() {
|
||||
wpi::print(stderr, "HTTP request: '{}'\n", m_request.GetUrl());
|
||||
wpi::UrlParser url{m_request.GetUrl(),
|
||||
m_request.GetMethod() == wpi::HTTP_CONNECT};
|
||||
wpi::util::print(stderr, "HTTP request: '{}'\n", m_request.GetUrl());
|
||||
wpi::net::UrlParser url{m_request.GetUrl(),
|
||||
m_request.GetMethod() == wpi::net::HTTP_CONNECT};
|
||||
if (!url.IsValid()) {
|
||||
// failed to parse URL
|
||||
SendError(400);
|
||||
@@ -37,15 +37,15 @@ void MyHttpServerConnection::ProcessRequest() {
|
||||
if (url.HasPath()) {
|
||||
path = url.GetPath();
|
||||
}
|
||||
wpi::print(stderr, "path: \"{}\"\n", path);
|
||||
wpi::util::print(stderr, "path: \"{}\"\n", path);
|
||||
|
||||
std::string_view query;
|
||||
if (url.HasQuery()) {
|
||||
query = url.GetQuery();
|
||||
}
|
||||
wpi::print(stderr, "query: \"{}\"\n", query);
|
||||
wpi::util::print(stderr, "query: \"{}\"\n", query);
|
||||
|
||||
const bool isGET = m_request.GetMethod() == wpi::HTTP_GET;
|
||||
const bool isGET = m_request.GetMethod() == wpi::net::HTTP_GET;
|
||||
if (isGET && path == "/") {
|
||||
// build HTML root page
|
||||
SendResponse(200, "OK", "text/html",
|
||||
@@ -59,7 +59,7 @@ void MyHttpServerConnection::ProcessRequest() {
|
||||
|
||||
int main() {
|
||||
// Kick off the event loop on a separate thread
|
||||
wpi::EventLoopRunner loop;
|
||||
wpi::net::EventLoopRunner loop;
|
||||
loop.ExecAsync([](uv::Loop& loop) {
|
||||
auto tcp = uv::Tcp::Create(loop);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user