WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
WebServer.hpp
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#pragma once
6
7#include <memory>
8#include <string_view>
9
10namespace wpi::net {
11
12/**
13 * A web server using the HTTP protocol.
14 */
15class WebServer {
16 public:
17 WebServer(const WebServer&) = delete;
18 WebServer& operator=(const WebServer&) = delete;
19
20 /**
21 * Get an instance of the WebServer class.
22 *
23 * This is a singleton to guarantee that there is only a single instance
24 * regardless of how many times GetInstance is called.
25 */
27
28 /**
29 * Create a web server at the given port.
30 * Note that local ports less than 1024 won't work as a normal user. Also,
31 * many ports are blocked by the FRC robot radio; check the game manual for
32 * what is allowed through the radio firewall.
33 *
34 * @param port local port number
35 * @param path local path to document root
36 */
37 void Start(unsigned int port, std::string_view path);
38
39 /**
40 * Stop web server running at the given port.
41 *
42 * @param port local port number
43 */
44 void Stop(unsigned int port);
45
46 private:
47 WebServer();
48
49 struct Impl;
50 std::unique_ptr<Impl> m_impl;
51};
52
53} // namespace wpi::net
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
void Stop(unsigned int port)
Stop web server running at the given port.
WebServer(const WebServer &)=delete
Definition raw_socket_ostream.hpp:9