mirror of
https://github.com/ohwgiles/laminar.git
synced 2024-10-27 20:34:20 +00:00
2e54773e83
User may provide a custom index.html template file to be used instead of the built-in version. Changes to this file are watched by laminard using inotify in order to load and compress the custom file for gzip delivery, reusing the existing method for serving static assets. This feature obviates the custom css feature, so remove references from the manual and add a deprecation warning if it is used. Add a section to the UserManual describing how to use this feature and including a link to an example using Semantic UI.
70 lines
2.3 KiB
C++
70 lines
2.3 KiB
C++
///
|
|
/// Copyright 2019 Oliver Giles
|
|
///
|
|
/// This file is part of Laminar
|
|
///
|
|
/// Laminar is free software: you can redistribute it and/or modify
|
|
/// it under the terms of the GNU General Public License as published by
|
|
/// the Free Software Foundation, either version 3 of the License, or
|
|
/// (at your option) any later version.
|
|
///
|
|
/// Laminar is distributed in the hope that it will be useful,
|
|
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
/// GNU General Public License for more details.
|
|
///
|
|
/// You should have received a copy of the GNU General Public License
|
|
/// along with Laminar. If not, see <http://www.gnu.org/licenses/>
|
|
///
|
|
#ifndef LAMINAR_HTTP_H_
|
|
#define LAMINAR_HTTP_H_
|
|
|
|
#include <kj/memory.h>
|
|
#include <kj/compat/http.h>
|
|
#include <string>
|
|
#include <set>
|
|
|
|
// Definition needed for musl
|
|
typedef unsigned int uint;
|
|
typedef unsigned long ulong;
|
|
|
|
struct Laminar;
|
|
struct Resources;
|
|
struct LogWatcher;
|
|
struct EventPeer;
|
|
|
|
class Http : public kj::HttpService {
|
|
public:
|
|
Http(Laminar&li);
|
|
virtual ~Http();
|
|
|
|
kj::Promise<void> startServer(kj::Timer &timer, kj::Own<kj::ConnectionReceiver> &&listener);
|
|
|
|
void notifyEvent(const char* data, std::string job = nullptr);
|
|
void notifyLog(std::string job, uint run, std::string log_chunk, bool eot);
|
|
|
|
// Allows supplying a custom HTML template. Pass an empty string to use the default.
|
|
void setHtmlTemplate(std::string tmpl = std::string());
|
|
|
|
private:
|
|
virtual kj::Promise<void> request(kj::HttpMethod method, kj::StringPtr url, const kj::HttpHeaders& headers,
|
|
kj::AsyncInputStream& requestBody, Response& response) override;
|
|
bool parseLogEndpoint(kj::StringPtr url, std::string &name, uint &num);
|
|
|
|
// With SSE, there is no notification if a client disappears. Also, an idle
|
|
// client must be kept alive if there is no activity in their MonitorScope.
|
|
// Deal with these by sending a periodic keepalive and reaping the client if
|
|
// the write fails.
|
|
kj::Promise<void> cleanupPeers(kj::Timer &timer);
|
|
|
|
Laminar& laminar;
|
|
std::set<EventPeer*> eventPeers;
|
|
kj::Own<kj::HttpHeaderTable> headerTable;
|
|
kj::Own<Resources> resources;
|
|
std::set<LogWatcher*> logWatchers;
|
|
|
|
kj::HttpHeaderId ACCEPT;
|
|
};
|
|
|
|
#endif //LAMINAR_HTTP_H_
|