File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -102,4 +102,6 @@ public void CompileRoutes()
102102 CompiledRoutes = compiledRoutes
103103 . ToArray ( ) ;
104104 }
105+
106+ [ JsonIgnore ] public static Regex ErrorCodePattern = new ( @"\s*\-\>\s*(\d+)\s*$" , RegexOptions . Compiled | RegexOptions . CultureInvariant ) ;
105107}
Original file line number Diff line number Diff line change @@ -10,7 +10,6 @@ public class RedirectController : Controller
1010{
1111
1212 private readonly Config Config ;
13-
1413
1514 private readonly Counter RouteCounter = Metrics . CreateCounter (
1615 "linkrouter_requests" ,
@@ -39,7 +38,6 @@ public RedirectController(Config config)
3938 [ HttpGet ( "/{*path}" ) ]
4039 public async Task < ActionResult > RedirectToExternalUrl ( string path )
4140 {
42-
4341 if ( ! path . EndsWith ( "/" ) )
4442 path += "/" ;
4543
@@ -65,6 +63,13 @@ public async Task<ActionResult> RedirectToExternalUrl(string path)
6563
6664 string redirectUrl = redirectRoute . RedirectUrl ;
6765
66+ if ( Config . ErrorCodePattern . IsMatch ( redirectUrl ) )
67+ {
68+ var errorCodeMatch = Config . ErrorCodePattern . Match ( redirectUrl ) ;
69+ var errorCode = int . Parse ( errorCodeMatch . Groups [ 1 ] . Value ) ;
70+ return StatusCode ( errorCode ) ;
71+ }
72+
6873 foreach ( var placeholder in redirectRoute . Placeholders )
6974 {
7075 var value = match . Groups [ placeholder . Value ] . Value ;
You can’t perform that action at this time.
0 commit comments