Created
January 19, 2017 06:23
-
-
Save justinyoo/4e1637b1394828ee0558a96c42f7b082 to your computer and use it in GitHub Desktop.
Testing Precompiled Azure Functions
This file contains 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
namespace PrecompiledLibraries | |
{ | |
public class MyHttpTrigger | |
{ | |
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log) | |
{ | |
var name = req.GetQueryNameValuePairs() | |
.FirstOrDefault(q => string.Compare(q.Key, "name", true) == 0) | |
.Value; | |
var res = new HttpResponseMessage(); | |
if (name == null) | |
{ | |
res.StatusCode = HttpStatusCode.BadRequest; | |
res.Content = new ObjectContent<string>("Please pass a name on the query string or in the request body", new JsonMediaTypeFormatter()); | |
return res; | |
} | |
res.StatusCode = HttpStatusCode.OK; | |
res.Content = new ObjectContent<string>($"Hello {name}", new JsonMediaTypeFormatter()); | |
return res; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment