WPILibC++ 2025.1.1
Loading...
Searching...
No Matches
WebServer.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#ifndef WPINET_WEBSERVER_H_
6#define WPINET_WEBSERVER_H_
7
8#pragma once
9
10#include <memory>
11#include <string_view>
12
13namespace wpi {
14
15/**
16 * A web server using the HTTP protocol.
17 */
18class WebServer {
19 public:
20 WebServer(const WebServer&) = delete;
21 WebServer& operator=(const WebServer&) = delete;
22
23 /**
24 * Get an instance of the WebServer class.
25 *
26 * This is a singleton to guarantee that there is only a single instance
27 * regardless of how many times GetInstance is called.
28 */
30
31 /**
32 * Create a web server at the given port.
33 * Note that local ports less than 1024 won't work as a normal user. Also,
34 * many ports are blocked by the FRC robot radio; check the game manual for
35 * what is allowed through the radio firewall.
36 *
37 * @param port local port number
38 * @param path local path to document root
39 */
40 void Start(unsigned int port, std::string_view path);
41
42 /**
43 * Stop web server running at the given port.
44 *
45 * @param port local port number
46 */
47 void Stop(unsigned int port);
48
49 private:
50 WebServer();
51
52 struct Impl;
53 std::unique_ptr<Impl> m_impl;
54};
55
56} // namespace wpi
57
58#endif // WPINET_WEBSERVER_H_
A web server using the HTTP protocol.
Definition WebServer.h:18
WebServer(const WebServer &)=delete
void Stop(unsigned int port)
Stop web server running at the given port.
void Start(unsigned int port, std::string_view path)
Create a web server at the given port.
static WebServer & GetInstance()
Get an instance of the WebServer class.
WebServer & operator=(const WebServer &)=delete
Foonathan namespace.
Definition ntcore_cpp.h:26