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 @@
## Bugfix
- fixed matomo visitor counting (broke since 2.7.0 release)
- fixed sane url generation
## Under the hood
......
......@@ -65,6 +65,9 @@
- [ ] on hover, show correct region name(s)
- [ ] whole mesh loads
## 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/julichbrain) redirects to julich brain (colin 27)
- [ ] [saneUrl](https://atlases.ebrains.eu/viewer-staging/saneUrl/whs4) redirects to waxholm v4
......
......@@ -4,23 +4,27 @@ import { throwError } from "rxjs";
import { catchError, mapTo } from "rxjs/operators";
import { BACKENDURL } from 'src/util/constants'
import { IKeyValStore, NotFoundError } from '../type'
import { DISABLE_PRIORITY_HEADER } from "src/util/priority"
@Injectable({
providedIn: 'root'
})
export class SaneUrlSvc implements IKeyValStore{
public saneUrlRoot = `${BACKENDURL}saneUrl/`
public saneUrlRoot = `${BACKENDURL}go/`
constructor(
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) {
return this.http.get<Record<string, any>>(
`${this.saneUrlRoot}${key}`,
{ responseType: 'json' }
{ responseType: 'json', headers: { [DISABLE_PRIORITY_HEADER]: '1' } }
).pipe(
catchError((err, obs) => {
const { status } = err
......@@ -35,7 +39,8 @@ export class SaneUrlSvc implements IKeyValStore{
setKeyVal(key: string, value: any) {
return this.http.post(
`${this.saneUrlRoot}${key}`,
value
value,
{ headers: { [DISABLE_PRIORITY_HEADER]: '1' } }
).pipe(
mapTo(`${this.saneUrlRoot}${key}`)
)
......
......@@ -24,6 +24,8 @@ type Queue = {
next: HttpHandler
}
export const DISABLE_PRIORITY_HEADER = 'x-sxplr-disable-priority'
@Injectable({
providedIn: 'root'
})
......@@ -137,8 +139,11 @@ export class PriorityHttpInterceptor implements HttpInterceptor{
* Since the way in which serialization occurs is via path and query param...
* body is not used.
*/
if (this.disablePriority || req.method !== 'GET') {
return next.handle(req)
if (this.disablePriority || req.method !== 'GET' || !!req.headers.get(DISABLE_PRIORITY_HEADER)) {
const newReq = req.clone({
headers: req.headers.delete(DISABLE_PRIORITY_HEADER)
})
return next.handle(newReq)
}
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