Skip to content

Commit

Permalink
more better?
Browse files Browse the repository at this point in the history
  • Loading branch information
Jef King committed Mar 15, 2017
1 parent 201c842 commit 7904eb3
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/StaticBlob/run.csx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ static string root = GetEnvironmentVariable("Root");

public static HttpResponseMessage Run(HttpRequestMessage req, TraceWriter log)
{
var uri = root
+ req.RequestUri.AbsolutePath
+ '/'
+ req.GetQueryNameValuePairs()
.FirstOrDefault(q => string.Compare(q.Key, "file", true) == 0)
.Value ?? defaultPage;

var path = req.GetQueryNameValuePairs()
.FirstOrDefault(q => string.Compare(q.Key, "file", true) == 0)
.Value ?? defaultPage;

var r = new HttpResponseMessage(HttpStatusCode.Redirect);
r.Headers.Location = new Uri(uri);
r.Headers.Location = new Uri($"{root}{req.RequestUri.AbsolutePath}/{path}");
return r;
}

Expand Down

0 comments on commit 7904eb3

Please sign in to comment.