Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Modern WebAPIS with ASP.NET Core
Search
Fabian Gosebrink
June 25, 2018
Technology
1
120
Modern WebAPIS with ASP.NET Core
Slides for my talk at the DWX 2018 in Nürnberg "Modern WebAPIs with ASP.NET Core"
Fabian Gosebrink
June 25, 2018
Tweet
Share
More Decks by Fabian Gosebrink
See All by Fabian Gosebrink
[iJS Munich] Better Angular Architectures with Libraries and Nx
fabiangosebrink
0
53
Mastering State Management in Angular with the NgRx Signal Store
fabiangosebrink
0
92
Angular Architectures with NgRx Stores & Effects
fabiangosebrink
0
42
Angular Testing made easy with Jest and Cypress
fabiangosebrink
0
50
Introducing NgRx in an Nx Angular Workspace
fabiangosebrink
0
240
Full-Stack-Web-Applications with Angular, Nx and .NET
fabiangosebrink
0
130
Angular Signals - Revolution in Angular development
fabiangosebrink
0
150
Kickstarting Your Journey with NgRx Signal Store
fabiangosebrink
0
100
Angular Signals under the Hood
fabiangosebrink
0
390
Other Decks in Technology
See All in Technology
SSMRunbook作成の勘所_20241120
koichiotomo
3
160
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
0
100
インフラとバックエンドとフロントエンドをくまなく調べて遅いアプリを早くした件
tubone24
1
430
プロダクト活用度で見えた真実 ホリゾンタルSaaSでの顧客解像度の高め方
tadaken3
0
180
CysharpのOSS群から見るModern C#の現在地
neuecc
2
3.5k
安心してください、日本語使えますよ―Ubuntu日本語Remix提供休止に寄せて― 2024-11-17
nobutomurata
1
1k
TypeScript、上達の瞬間
sadnessojisan
46
13k
Why App Signing Matters for Your Android Apps - Android Bangkok Conference 2024
akexorcist
0
130
10XにおけるData Contractの導入について: Data Contract事例共有会
10xinc
6
660
心が動くエンジニアリング ── 私が夢中になる理由
16bitidol
0
100
【Pycon mini 東海 2024】Google Colaboratoryで試すVLM
kazuhitotakahashi
2
540
Engineer Career Talk
lycorp_recruit_jp
0
190
Featured
See All Featured
A Philosophy of Restraint
colly
203
16k
Mobile First: as difficult as doing things right
swwweet
222
8.9k
How STYLIGHT went responsive
nonsquared
95
5.2k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Designing for Performance
lara
604
68k
Practical Orchestrator
shlominoach
186
10k
Navigating Team Friction
lara
183
14k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
47
2.1k
What's new in Ruby 2.0
geeforr
343
31k
Automating Front-end Workflow
addyosmani
1366
200k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Transcript
with Building modern WebAPIs ASP.NET Core
None
None
None
@FabianGosebrink
None
https://developer-academy.ch
with Building modern WebAPIs ASP.NET Core
What is ASP.NET Core?
MVC + WebAPI + Web Pages
None
Faster Deployment Cycles
None
Tooling
DOTNET CLI fabian gosebrink
class Program { static void Main(string[] args) { Console.WriteLine("Hello World!");
} }
DOTNET CLI fabian gosebrink
Program.cs 1. public class Program 2. { 3. public static
void Main(string[] args) 4. { 5. CreateWebHostBuilder(args).Build().Run(); 6. } 7. 8. public static IWebHostBuilder CreateWebHostBuilder(string[] args) => 9. WebHost.CreateDefaultBuilder(args) 10. .UseStartup<Startup>(); 11. }
public static IWebHostBuilder CreateDefaultBuilder(string[] args) { var builder = new
WebHostBuilder(); builder.UseKestrel(...) .ConfigureAppConfiguration((hostingContext, config) => { config.AddJsonFile( "appsettings.json", optional: true, reloadOnChange: true); }) .ConfigureLogging((hostingContext, logging) => { logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging")); logging.AddConsole(); logging.AddDebug(); }) .ConfigureServices((hostingContext, services) => { //... }) .UseIISIntegration(); return builder; }
Dependency Injection
Startup.cs 1. public class Startup 2. { 3. public Startup(IConfiguration
configuration) 4. { 5. Configuration = configuration; 6. } 7. 8. public IConfiguration Configuration { get; } 9. 10. public void ConfigureServices(IServiceCollection services) 11. { 12. services.AddOptions(); 13. 14. services.AddCors(...); 15.
Kestrel
None
REST
What is Rest?
Rest is not WebAPI
Rest is not HTTP
None
Architectural Style
GET /api/orders/ GET /api/orders/1 POST /api/orders/ PUT /api/orders/1 DELETE /api/orders/1
Rest Constraints
Richardson Maturity Model
STATUSCODES
export const isSuccess = (status): boolean => (status >= 200
&& status < 300)
2xx
4xx
5xx
The Controller 1. [Route("api/[controller]")] 2. public class FoodController : Controller
3. { 4. private readonly IFoodRepository _foodRepository; 5. 6. public FoodController(IFoodRepository foodRepository) 7. { 8. _foodRepository = foodRepository; 9. } 10. 11. [HttpGet] 12. public ActionResult<List<FoodItemDto>> Get() 13. { 14. ICollection<FoodItem> foodItems = _foodRepository.GetAll(); 15. IEnumerable<FoodItemDto> dtos = foodItems 16. .Select(x => Mapper.Map<FoodItemDto>(x)); 17. 18. return Ok(dtos);
Documentation
Documentation
None
VERSIONING
document.docx
document- nal.docx
document- nal- nal.docx
document-really- nal.docx
document-really- nal-end- of-discussion.docx
document-really- nal- approved-by- customer.docx
document-really- nal- approved-by-customer- with-alterations- suggested-by-his- assistant.docx
document-really- nal-approved- by-customer-with-alterations- suggested-by-his-assistant-and- his-friend-cause-apparently-he- thinks-he-knows-all-about-good- api-design
document-really- nal-approved- by-customer-with-alterations- suggested-by-his-assistant-and- his-friend-cause-apparently-he- thinks-he-knows-all-about-good- api-design.docx
None
None
DEMO
/api/houses?page=4&pageSize=10
/api/houses?orderby=Id
/api/houses?fields=street,number
HATEOAS
{ "departmentId": 10, "departmentName": "Administration", "locationId": 1700, "managerId": 200, "links":
[ { "href": "10/employees", "rel": "employees", "type" : "GET" } ] }
SignalR
None
None
None
Le Fin
@FabianGosebrink https://offering.solutions/
[email protected]
https://github.com/FabianGosebrink https://github.com/FabianGosebrink/ASPNETCore- WebAPI-Sample
Resources https://media.giphy.com/media/1BXa2alBjrCXC/giphy.gif http://img0.joyreactor.com/pics/post/photo-india-it-programmer-548432.jpeg