File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
templates/typescript/templated Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ export interface Options {
1414 type: "websocket" | "http" | "https";
1515 host: string;
1616 port: number;
17+ path?: string;
1718 }
1819}
1920
@@ -28,15 +29,19 @@ export class <%= className %> {
2829 if (options.transport === undefined || options.transport.type === undefined) {
2930 throw new Error("Invalid constructor params");
3031 }
31-
32+ const {type, host, port} = options.transport;
33+ let path = options.transport.path || "";
34+ if(path && path[0] !== "/") {
35+ path = "/" + path;
36+ }
3237 let transport;
33- switch (options.transport. type) {
38+ switch (type) {
3439 case 'http':
3540 case 'https':
36- transport = new HTTPTransport(options.transport. type + "://" + options.transport. host + ":" + options.transport. port)
41+ transport = new HTTPTransport(type + "://" + host + ":" + port + path )
3742 break;
3843 case 'websocket':
39- transport = new WebSocketTransport("ws://" + options.transport. host + ":" + options.transport. port)
44+ transport = new WebSocketTransport("ws://" + host + ":" + port + path )
4045 break;
4146 default:
4247 throw new Error("unsupported transport");
You can’t perform that action at this time.
0 commit comments