Last active
October 25, 2018 10:43
-
-
Save michael-wolfenden/eb8cbefba8511c2be5fea7c1b71ee117 to your computer and use it in GitHub Desktop.
aspnetcore microservice - linqpad
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
<Query Kind="Program"> | |
<NuGetReference>Microsoft.AspNetCore</NuGetReference> | |
<NuGetReference>Microsoft.AspNetCore.Mvc.Core</NuGetReference> | |
<NuGetReference>Microsoft.AspNetCore.Mvc.Formatters.Json</NuGetReference> | |
<NuGetReference>System.ValueTuple</NuGetReference> | |
<Namespace>Microsoft.AspNetCore</Namespace> | |
<Namespace>Microsoft.AspNetCore.Builder</Namespace> | |
<Namespace>Microsoft.AspNetCore.Hosting</Namespace> | |
<Namespace>Microsoft.AspNetCore.Mvc</Namespace> | |
<Namespace>Microsoft.Extensions.DependencyInjection</Namespace> | |
</Query> | |
#define NONEST | |
public class Microservice : ControllerBase | |
{ | |
[HttpGet("/")] | |
public IActionResult Hello() => | |
new JsonResult(new { Message = "Hello World" }); | |
public void Configure(IApplicationBuilder applicationBuilder, IHostingEnvironment env) => | |
applicationBuilder | |
.UseMvc(); | |
public void ConfigureServices(IServiceCollection services) => | |
services | |
.AddMvcCore() | |
.AddJsonFormatters(); | |
private static void Main(string[] args) | |
{ | |
using (var host = WebHost | |
.CreateDefaultBuilder(args) | |
.UseStartup<Microservice>() | |
.Build()) | |
{ | |
host.Start(); | |
Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm getting an error when restoring nuget packages