mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-13 13:03:04 +00:00
Solved issue with non-existing search pages
This commit is contained in:
26
src/app/core/services/server-response.service.ts
Normal file
26
src/app/core/services/server-response.service.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { RESPONSE } from '@nguniversal/express-engine/tokens';
|
||||
import { Inject, Injectable, Optional } from '@angular/core';
|
||||
import { Response } from 'express';
|
||||
|
||||
@Injectable()
|
||||
export class ServerResponseService {
|
||||
private response: Response;
|
||||
|
||||
constructor(@Optional() @Inject(RESPONSE) response: any) {
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
setStatus(code: number, message?: string): this {
|
||||
if (this.response) {
|
||||
this.response.statusCode = code;
|
||||
if (message) {
|
||||
this.response.statusMessage = message;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
setNotFound(message = 'Not found'): this {
|
||||
return this.setStatus(404, message)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user