Commit eca5e4f 1 parent 9b81505 commit eca5e4f Copy full SHA for eca5e4f
File tree 2 files changed +17
-0
lines changed
2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -89,6 +89,21 @@ export default class ExegesisResponseImpl implements types.ExegesisResponse {
89
89
this . ended = true ;
90
90
}
91
91
92
+ redirect ( status : number , url : string ) : this;
93
+ redirect ( url : string ) : this;
94
+ redirect ( a : number | string , b ?: string ) : this {
95
+ if ( typeof a === 'string' && ! b ) {
96
+ this . writeHead ( 302 , { Location : a } ) ;
97
+ } else if ( typeof a === 'number' && typeof b === 'string' ) {
98
+ this . writeHead ( a , { Location : b } ) ;
99
+ } else {
100
+ throw new Error ( 'Invalid arguments to redirect' ) ;
101
+ }
102
+ this . end ( ) ;
103
+
104
+ return this ;
105
+ }
106
+
92
107
setHeader ( name : string , value : number | string | string [ ] ) {
93
108
if ( this . ended && ! this . _afterController ) {
94
109
throw new Error ( 'Trying to set header after response has been ended.' ) ;
Original file line number Diff line number Diff line change @@ -51,6 +51,8 @@ export interface ExegesisResponse {
51
51
*/
52
52
pureJson ( json : any ) : this;
53
53
end ( ) : void ;
54
+ redirect ( status : number , url : string ) : this;
55
+ redirect ( url : string ) : this;
54
56
setHeader ( name : string , value : number | string | string [ ] | undefined ) : void ;
55
57
getHeader ( name : string ) : number | string | string [ ] | undefined ;
56
58
getHeaderNames ( ) : string [ ] ;
You can’t perform that action at this time.
0 commit comments