Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(bitbucket-server): Switch to new http wrapper (#6393)
- Loading branch information
Showing
4 changed files
with
112 additions
and
73 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import URL from 'url'; | ||
import { PLATFORM_TYPE_BITBUCKET_SERVER } from '../../constants/platforms'; | ||
import { Http, HttpOptions, HttpResponse, InternalHttpOptions } from '.'; | ||
|
||
let baseUrl: string; | ||
export const setBaseUrl = (url: string): void => { | ||
baseUrl = url; | ||
}; | ||
|
||
export class BitbucketServerHttp extends Http { | ||
constructor(options?: HttpOptions) { | ||
super(PLATFORM_TYPE_BITBUCKET_SERVER, options); | ||
} | ||
|
||
protected async request<T>( | ||
path: string, | ||
options?: InternalHttpOptions | ||
): Promise<HttpResponse<T> | null> { | ||
const url = URL.resolve(baseUrl, path); | ||
const opts = { | ||
baseUrl, | ||
...options, | ||
}; | ||
opts.headers = { | ||
...opts.headers, | ||
'X-Atlassian-Token': 'no-check', | ||
}; | ||
return super.request<T>(url, opts); | ||
} | ||
} |