mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-24 09:08:07 +02:00
Improve the webserver's constructor
This makes the webserver configurable during instantiation rather than having to set the parameters afterwards.
This commit is contained in:
parent
985ba77579
commit
2e6fa797d9
3 changed files with 12 additions and 12 deletions
|
@ -1015,11 +1015,12 @@ async function startBrowsers({ baseUrl, initializeSession }) {
|
|||
}
|
||||
|
||||
function startServer() {
|
||||
server = new WebServer();
|
||||
server.host = host;
|
||||
server.port = options.port;
|
||||
server.root = "..";
|
||||
server.cacheExpirationTime = 3600;
|
||||
server = new WebServer({
|
||||
root: "..",
|
||||
host,
|
||||
port: options.port,
|
||||
cacheExpirationTime: 3600,
|
||||
});
|
||||
server.start();
|
||||
}
|
||||
|
||||
|
|
|
@ -38,13 +38,13 @@ const MIME_TYPES = {
|
|||
const DEFAULT_MIME_TYPE = "application/octet-stream";
|
||||
|
||||
class WebServer {
|
||||
constructor() {
|
||||
this.root = ".";
|
||||
this.host = "localhost";
|
||||
this.port = 0;
|
||||
constructor({ root, host, port, cacheExpirationTime }) {
|
||||
this.root = root || ".";
|
||||
this.host = host || "localhost";
|
||||
this.port = port || 0;
|
||||
this.server = null;
|
||||
this.verbose = false;
|
||||
this.cacheExpirationTime = 0;
|
||||
this.cacheExpirationTime = cacheExpirationTime || 0;
|
||||
this.disableRangeRequests = false;
|
||||
this.hooks = {
|
||||
GET: [crossOriginHandler],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue