# आपकी पहली Minimal API — .NET Core: वेब API बनाएँ, टेस्ट करें और शिप करें

Source: https://www.geekswithgeeks.com/hi/dotnet-core/api-minimal-hello

> एक endpoint वाला web ऐप बनाएँ और builder व app objects को समझें।

## पहले builder, फिर app

`WebApplication.CreateBuilder` configuration और services इकट्ठा करता है। `builder.Build()` से `app` बनता है, जहाँ आप endpoints map करते और middleware जोड़ते हैं। `app.Run()` web server (Kestrel) शुरू करता है।

## HTTP request का जीवन

Request middleware से गुज़रती है, endpoint से मिलती है, आपका handler चलाती है, और response वापस जाता है।

![आने वाली request से जाने वाले response तक पाँच चरण।](assets/figures/dotnet-core/section-4-map.svg) — चित्र 4.1 — ASP.NET Core request pipeline।

## Program.cs

इसे `dotnet new web` से बनाएँ। यह `/` पर एक GET endpoint map करता है जो text लौटाता है।

```csharp
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

app.MapGet("/", () => "Hello from .NET");

app.Run();
```

## Port के लिए launchSettings उपयोग करें

Development में port `Properties/launchSettings.json` से आता है। Production में उसे code में लिखने के बजाय `ASPNETCORE_URLS` environment variable से सेट करें।

**Quiz:** Minimal API में GET endpoint कौन-सी call map करती है?

- [ ] app.UseGet
- [x] app.MapGet
- [ ] builder.AddGet
- [ ] app.RunGet

*Answer:* app.MapGet. `MapGet(pattern, handler)` किसी route पर GET requests के लिए handler दर्ज करता है।
