Created
August 23, 2016 06:21
-
-
Save Kevin-Bronsdijk/c73a7d55bfc8ea6454184ac34c7778c4 to your computer and use it in GitHub Desktop.
Azure Functions devslice.net
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "Newtonsoft.Json" | |
using System; | |
using System.Net; | |
using Newtonsoft.Json; | |
using GTmetrix; | |
using GTmetrix.Http; | |
using GTmetrix.Model; | |
public static async Task<object> Run(HttpRequestMessage req, TraceWriter log) | |
{ | |
string jsonContent = await req.Content.ReadAsStringAsync(); | |
dynamic data = JsonConvert.DeserializeObject(jsonContent); | |
if (data.url == null) { | |
return req.CreateResponse(HttpStatusCode.BadRequest, new { | |
error = "Please provide a url" | |
}); | |
} | |
var client = new Client(Connection.Create("your_key", "your_username")); | |
var response = client.SubmitTestAsync(new TestRequest( | |
new Uri(data.url.ToString()), | |
Locations.London, | |
Browsers.Chrome)); | |
var result = response.Result; | |
return req.CreateResponse(response.Result.StatusCode, response.Result); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"frameworks": { | |
"net46":{ | |
"dependencies": { | |
"GTmetrix": "0.1.0" | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment