MCPcopy
hub / github.com/socketio/socket.io / attachServe

Method attachServe

packages/socket.io/lib/index.ts:617–637  ·  view source on GitHub ↗

* Attaches the static file serving. * * @param srv http server * @private

(srv: TServerInstance)

Source from the content-addressed store, hash-verified

615 * @private
616 */
617 private attachServe(srv: TServerInstance): void {
618 debug("attaching client serving req handler");
619
620 const evs = srv.listeners("request").slice(0);
621 srv.removeAllListeners("request");
622 srv.on("request", (req, res) => {
623 if (this.clientPathRegex.test(req.url!)) {
624 if (this._corsMiddleware) {
625 this._corsMiddleware(req, res, () => {
626 this.serve(req, res);
627 });
628 } else {
629 this.serve(req, res);
630 }
631 } else {
632 for (let i = 0; i < evs.length; i++) {
633 evs[i].call(srv, req, res);
634 }
635 }
636 });
637 }
638
639 /**
640 * Handles a request serving of client source and map

Callers 1

initEngineMethod · 0.95

Calls 3

serveMethod · 0.95
debugFunction · 0.85
onMethod · 0.45

Tested by

no test coverage detected