Skip to content
Snippets Groups Projects
Commit 622aca90 authored by Xiao Gui's avatar Xiao Gui
Browse files

fix saneurl

parent 8798cc16
No related branches found
No related tags found
No related merge requests found
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
## Bugfix ## Bugfix
- fixed matomo visitor counting (broke since 2.7.0 release) - fixed matomo visitor counting (broke since 2.7.0 release)
- fixed sane url generation
## Under the hood ## Under the hood
......
...@@ -65,6 +65,9 @@ ...@@ -65,6 +65,9 @@
- [ ] on hover, show correct region name(s) - [ ] on hover, show correct region name(s)
- [ ] whole mesh loads - [ ] whole mesh loads
## saneURL ## saneURL
- [ ] saneurl generation functions properly
- [ ] try existing key (human), and get unavailable error
- [ ] try non existing key, and get available
- [ ] [saneUrl](https://atlases.ebrains.eu/viewer-staging/saneUrl/bigbrainGreyWhite) redirects to big brain - [ ] [saneUrl](https://atlases.ebrains.eu/viewer-staging/saneUrl/bigbrainGreyWhite) redirects to big brain
- [ ] [saneUrl](https://atlases.ebrains.eu/viewer-staging/saneUrl/julichbrain) redirects to julich brain (colin 27) - [ ] [saneUrl](https://atlases.ebrains.eu/viewer-staging/saneUrl/julichbrain) redirects to julich brain (colin 27)
- [ ] [saneUrl](https://atlases.ebrains.eu/viewer-staging/saneUrl/whs4) redirects to waxholm v4 - [ ] [saneUrl](https://atlases.ebrains.eu/viewer-staging/saneUrl/whs4) redirects to waxholm v4
......
...@@ -4,23 +4,27 @@ import { throwError } from "rxjs"; ...@@ -4,23 +4,27 @@ import { throwError } from "rxjs";
import { catchError, mapTo } from "rxjs/operators"; import { catchError, mapTo } from "rxjs/operators";
import { BACKENDURL } from 'src/util/constants' import { BACKENDURL } from 'src/util/constants'
import { IKeyValStore, NotFoundError } from '../type' import { IKeyValStore, NotFoundError } from '../type'
import { DISABLE_PRIORITY_HEADER } from "src/util/priority"
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
export class SaneUrlSvc implements IKeyValStore{ export class SaneUrlSvc implements IKeyValStore{
public saneUrlRoot = `${BACKENDURL}saneUrl/` public saneUrlRoot = `${BACKENDURL}go/`
constructor( constructor(
private http: HttpClient private http: HttpClient
){ ){
if (!BACKENDURL) {
const loc = window.location
this.saneUrlRoot = `${loc.protocol}//${loc.hostname}${!!loc.port ? (':' + loc.port) : ''}${loc.pathname}go/`
}
} }
getKeyVal(key: string) { getKeyVal(key: string) {
return this.http.get<Record<string, any>>( return this.http.get<Record<string, any>>(
`${this.saneUrlRoot}${key}`, `${this.saneUrlRoot}${key}`,
{ responseType: 'json' } { responseType: 'json', headers: { [DISABLE_PRIORITY_HEADER]: '1' } }
).pipe( ).pipe(
catchError((err, obs) => { catchError((err, obs) => {
const { status } = err const { status } = err
...@@ -35,7 +39,8 @@ export class SaneUrlSvc implements IKeyValStore{ ...@@ -35,7 +39,8 @@ export class SaneUrlSvc implements IKeyValStore{
setKeyVal(key: string, value: any) { setKeyVal(key: string, value: any) {
return this.http.post( return this.http.post(
`${this.saneUrlRoot}${key}`, `${this.saneUrlRoot}${key}`,
value value,
{ headers: { [DISABLE_PRIORITY_HEADER]: '1' } }
).pipe( ).pipe(
mapTo(`${this.saneUrlRoot}${key}`) mapTo(`${this.saneUrlRoot}${key}`)
) )
......
...@@ -24,6 +24,8 @@ type Queue = { ...@@ -24,6 +24,8 @@ type Queue = {
next: HttpHandler next: HttpHandler
} }
export const DISABLE_PRIORITY_HEADER = 'x-sxplr-disable-priority'
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
...@@ -137,8 +139,11 @@ export class PriorityHttpInterceptor implements HttpInterceptor{ ...@@ -137,8 +139,11 @@ export class PriorityHttpInterceptor implements HttpInterceptor{
* Since the way in which serialization occurs is via path and query param... * Since the way in which serialization occurs is via path and query param...
* body is not used. * body is not used.
*/ */
if (this.disablePriority || req.method !== 'GET') { if (this.disablePriority || req.method !== 'GET' || !!req.headers.get(DISABLE_PRIORITY_HEADER)) {
return next.handle(req) const newReq = req.clone({
headers: req.headers.delete(DISABLE_PRIORITY_HEADER)
})
return next.handle(newReq)
} }
const { urlWithParams } = req const { urlWithParams } = req
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment