Merge pull request #291 from lbryio/connection-string-override
Connection string override
This commit is contained in:
commit
7517aceb07
4 changed files with 14 additions and 2 deletions
5
dist/bundle.es.js
vendored
5
dist/bundle.es.js
vendored
|
@ -884,6 +884,8 @@ const Lbry = {
|
|||
isConnected: false,
|
||||
connectPromise: null,
|
||||
daemonConnectionString: 'http://localhost:5279',
|
||||
alternateConnectionString: '',
|
||||
methodsUsingAlternateConnectionString: [],
|
||||
apiRequestHeaders: { 'Content-Type': 'application/json-rpc' },
|
||||
|
||||
// Allow overriding daemon connection string (e.g. to `/api/proxy` for lbryweb)
|
||||
|
@ -1052,7 +1054,8 @@ function apiCall(method, params, resolve, reject) {
|
|||
})
|
||||
};
|
||||
|
||||
return fetch(Lbry.daemonConnectionString + '?m=' + method, options).then(checkAndParse).then(response => {
|
||||
const connectionString = Lbry.methodsUsingAlternateConnectionString.includes(method) ? Lbry.alternateConnectionString : Lbry.daemonConnectionString;
|
||||
return fetch(connectionString + '?m=' + method, options).then(checkAndParse).then(response => {
|
||||
const error = response.error || response.result && response.result.error;
|
||||
|
||||
if (error) {
|
||||
|
|
2
dist/flow-typed/Lbry.js
vendored
2
dist/flow-typed/Lbry.js
vendored
|
@ -221,6 +221,8 @@ declare type LbryTypes = {
|
|||
connectPromise: ?Promise<any>,
|
||||
connect: () => void,
|
||||
daemonConnectionString: string,
|
||||
alternateConnectionString: string,
|
||||
methodsUsingAlternateConnectionString: Array<string>,
|
||||
apiRequestHeaders: { [key: string]: string },
|
||||
setDaemonConnectionString: string => void,
|
||||
setApiHeader: (string, string) => void,
|
||||
|
|
2
flow-typed/Lbry.js
vendored
2
flow-typed/Lbry.js
vendored
|
@ -221,6 +221,8 @@ declare type LbryTypes = {
|
|||
connectPromise: ?Promise<any>,
|
||||
connect: () => void,
|
||||
daemonConnectionString: string,
|
||||
alternateConnectionString: string,
|
||||
methodsUsingAlternateConnectionString: Array<string>,
|
||||
apiRequestHeaders: { [key: string]: string },
|
||||
setDaemonConnectionString: string => void,
|
||||
setApiHeader: (string, string) => void,
|
||||
|
|
|
@ -11,6 +11,8 @@ const Lbry: LbryTypes = {
|
|||
isConnected: false,
|
||||
connectPromise: null,
|
||||
daemonConnectionString: 'http://localhost:5279',
|
||||
alternateConnectionString: '',
|
||||
methodsUsingAlternateConnectionString: [],
|
||||
apiRequestHeaders: { 'Content-Type': 'application/json-rpc' },
|
||||
|
||||
// Allow overriding daemon connection string (e.g. to `/api/proxy` for lbryweb)
|
||||
|
@ -191,7 +193,10 @@ export function apiCall(method: string, params: ?{}, resolve: Function, reject:
|
|||
}),
|
||||
};
|
||||
|
||||
return fetch(Lbry.daemonConnectionString + '?m=' + method, options)
|
||||
const connectionString = Lbry.methodsUsingAlternateConnectionString.includes(method)
|
||||
? Lbry.alternateConnectionString
|
||||
: Lbry.daemonConnectionString;
|
||||
return fetch(connectionString + '?m=' + method, options)
|
||||
.then(checkAndParse)
|
||||
.then(response => {
|
||||
const error = response.error || (response.result && response.result.error);
|
||||
|
|
Loading…
Reference in a new issue