Skip to content

Commit

Permalink
add host
Browse files Browse the repository at this point in the history
  • Loading branch information
AitorAlgorta committed Feb 13, 2024
1 parent 72fafb0 commit f98f9e6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions backend/components/schema-registry-manager/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ app.get('/schemas.provider', (req: Request, res: Response) => {
app.get('/schemas.list', (req: Request, res: Response) => {
switch (currentProvider) {
case SchemaProvider.karapace:
getSchemas()
getSchemas(req.get('host') as string)
.then((response: string[]) => {
res.send(response);
})
Expand All @@ -61,7 +61,7 @@ app.get('/schemas.versions', (req: Request, res: Response) => {

switch (currentProvider) {
case SchemaProvider.karapace:
getSchemaVersions(req.query.topicName as string)
getSchemaVersions(req.get('host') as string, req.query.topicName as string)
.then((response: any) => {
res.status(200).send(response);
})
Expand All @@ -88,7 +88,7 @@ app.get('/schemas.info', (req: Request, res: Response) => {

switch (currentProvider) {
case SchemaProvider.karapace:
getSchemaInfo(req.query.topicName as string, version)
getSchemaInfo(req.get('host') as string, req.query.topicName as string, version)
.then((response: any) => {
res.status(200).send(response);
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
export async function getSchemas() {
return getData('subjects').then(response => {
export async function getSchemas(host: string) {
return getData(host, 'subjects').then(response => {
return response;
});
}

export async function getSchemaVersions(topicName: string) {
return getData(`subjects/${topicName}/versions`).then(response => {
export async function getSchemaVersions(host: string, topicName: string) {
return getData(host, `subjects/${topicName}/versions`).then(response => {
if (response.error_code && response.error_code.toString().includes('404') && !topicName.includes('-value')) {
return Promise.reject('404 Not Found');
}
return response;
});
}

export async function getSchemaInfo(topicName: string, version: string) {
return getData(`subjects/${topicName}/versions/${version}`).then(response => {
export async function getSchemaInfo(host: string, topicName: string, version: string) {
return getData(host, `subjects/${topicName}/versions/${version}`).then(response => {
if (response.error_code && response.error_code.toString().includes('404') && !topicName.includes('-value')) {
return Promise.reject('404 Not Found');
}
Expand Down Expand Up @@ -94,8 +94,8 @@ export async function getLastMessage(topicName: string) {
});
}

async function getData(url: string) {
const response = await fetch(process.env.URL + '/' + url, {
async function getData(host: string, url: string) {
const response = await fetch('https://' + host + '/' + url, {
method: 'GET',
});
return response.json();
Expand Down

0 comments on commit f98f9e6

Please sign in to comment.