Skip to content

Instantly share code, notes, and snippets.

@jsheridanwells
Created June 2, 2020 19:50
Show Gist options
  • Save jsheridanwells/f46be63d2179b955fdc2ee67712bab53 to your computer and use it in GitHub Desktop.
Save jsheridanwells/f46be63d2179b955fdc2ee67712bab53 to your computer and use it in GitHub Desktop.
weather-walking-skeleton-part_0
# bash
$ dotnet new webapi -o WeatherWalkingSkeleton
# bash
├── Controllers
│   └── WeatherForecastController.cs
├── Program.cs
├── Properties
│   └── launchSettings.json
├── Startup.cs
├── WeatherForecast.cs
├── WeatherWalkingSkeleton.csproj
├── appsettings.Development.json
├── appsettings.json
// Program.cs
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
// WeatherForecastController.cs
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
// [...]
[HttpGet]
public IEnumerable<WeatherForecast> Get()
{
// [...]
}
}
info: Microsoft.Hosting.Lifetime[0]
Now listening on: https://localhost:5001
info: Microsoft.Hosting.Lifetime[0]
Now listening on: http://localhost:5000
# bash
curl https://localhost:5001/WeatherForecast -k
[
{
"date": "2020-05-26T13:06:20.464957-05:00",
"temperatureC": -9,
"temperatureF": 16,
"summary": "Warm"
},
{
"date": "2020-05-27T13:06:20.464998-05:00",
"temperatureC": -20,
"temperatureF": -3,
"summary": "Scorching"
},
{
"date": "2020-05-28T13:06:20.464999-05:00",
"temperatureC": 49,
"temperatureF": 120,
"summary": "Balmy"
},
{
"date": "2020-05-29T13:06:20.465-05:00",
"temperatureC": 9,
"temperatureF": 48,
"summary": "Mild"
},
{
"date": "2020-05-30T13:06:20.465-05:00",
"temperatureC": -9,
"temperatureF": 16,
"summary": "Freezing"
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment