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
110
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
Angular Architectures with NgRx Stores & Effects
fabiangosebrink
0
70
Angular Testing made easy with Jest and Cypress
fabiangosebrink
0
78
From Desktop to web and back
fabiangosebrink
0
17
Better Angular Architectures with Libraries and Nx
fabiangosebrink
0
240
Developing forms and validation with Typed Angular Reactive Forms
fabiangosebrink
0
46
Angular Testing made easy with Jest and Cypress
fabiangosebrink
0
58
Monorepos with Angular and Nx
fabiangosebrink
0
120
Create modern Web Apps with the new Angular and it's ecosystem
fabiangosebrink
0
85
Realtime Cross Platform Apps with Angular, ASP.NET Core and SignalR
fabiangosebrink
0
120
Other Decks in Technology
See All in Technology
レガシーをぶっ壊せ。AEONで始めるDevRelの話 / Qiita Night 2024-2-22
aeonpeople
3
1.2k
Tableau事例紹介 / Tableau Case Study of Eureka
kazuya_araki_tokyo
1
180
少数チームで挑む: SwiftUI, TCA, KMPを用いた 新規動画配信アプリ 「ABEMA Live」の開発について
tomu28
0
610
Delivering Millions of Messages within seconds @ Duolingo
pelelgrino
0
340
生産性向上チームの紹介
cybozuinsideout
PRO
1
850
DevOpsDays History and my DevOps story
kawaguti
PRO
9
2.3k
アクセシビリティを考慮したUI/CSSフレームワーク・ライブラリ選定
yajihum
2
980
本当のAWS基礎
toru_kubota
0
390
どうするコスト最適化のトレードオフ
tetsuyaooooo
1
460
私が trocco を推す理由
__allllllllez__
1
190
チームでロジカルシンキングに改めて向き合っている話 〜学習環境と実践⽅法〜
sansantech
PRO
0
360
JAWS-UG Bedrock Claude Night
yamahiro
3
480
Featured
See All Featured
What's in a price? How to price your products and services
michaelherold
237
11k
How GitHub (no longer) Works
holman
304
140k
Robots, Beer and Maslow
schacon
PRO
155
7.9k
Typedesign – Prime Four
hannesfritz
36
2.1k
Web development in the modern age
philhawksworth
202
10k
GitHub's CSS Performance
jonrohan
1024
450k
The Illustrated Children's Guide to Kubernetes
chrisshort
30
46k
Why Our Code Smells
bkeepers
PRO
331
56k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
115
18k
Visualization
eitanlees
135
14k
Gamification - CAS2011
davidbonilla
76
4.6k
Building Your Own Lightsaber
phodgson
98
5.7k
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