Presentation is loading. Please wait.

Presentation is loading. Please wait.

Building production-ready APIs with ASP.NET Core 2.2

Similar presentations


Presentation on theme: "Building production-ready APIs with ASP.NET Core 2.2"— Presentation transcript:

1 Building production-ready APIs with ASP.NET Core 2.2
Miroslav Popović @miroslavpopovic Building production-ready APIs with ASP.NET Core 2.2

2 Thanks to our partners!

3 Introduction

4 REST(ful) REST RESTful Web resources – identified with URL address
architecture type that’s using the existing web infrastructure RESTful services that implement REST architecture Web resources – identified with URL address HTTP verbs – GET, POST, PUT, DELETE, PATCH… JSON or XML Strict and pragmatic approach

5 ASP.NET Core Benefits Performance Cross-platform Dependency injection
Middleware / action filters Routing (conventions and attributes) Content negotiation (JSON, XML,…) Configuration (environment specific, user secrets…) Logging

6 ASP.NET Core 2.1 Making MVC into an opinionated, forward-thinking, batteries included framework for HTTP APIs HTTPS by default [ApiController] ActionResult<T> Kestrel on Sockets

7 ASP.NET Core 2.2 (preview 3) API Conventions API Analyzers
HTTP/2 in Kestrel Health Checks Endpoint Routing HTTP/REPL

8 Production-ready?

9 Best practices IActionResult, ActionResult<T> View Models
Model / input validation Exception handling Logging Paging 2.1 2.1

10 Security HTTPS OAuth 2.0 Identity Server 4 Third party
Token based authentication Identity Server 4 Third party Auth0 - Okta - 2.1

11 Testing Unit testing & Integration testing Manual testing
Tools (Postman, Fiddler…) Stress/load testing

12 Documentation http://swagger.io/ -> https://www.openapis.org/
Swagger -> Open API Specification 3.0 API framework Docs Define an API Automate API testing Code generation ... API Analyzers - Microsoft.AspNetCore.Mvc.Api.Analyzers Swashbuckle or NSwag and Swagger UI 2.1 2.2 2.2

13 Rainbows and unicorns Image source:

14 Usage limiting Limit per token With middleware or action filter
Limit per Client IP Limit per Client ID header

15 Versioning URL Query string Custom request header Accept header
/api/v2/games/ Query string /api/games?api-version=2 Custom request header api-version: 2 Accept header Accept: application/json;v=2 Microsoft.AspNetCore.Mvc.Versioning Supports all types, query string by default (?api-version=2)

16 Monitoring Simple logging – errors, logs Performance tracking
Usage tracking Azure – Azure Monitor, Application Insights, Log Analytics … ASP.NET Core Health Checks Warden, open-source, cross-platform health checks Third-party monitoring services 2.2

17 Closing up @miroslavpopovic

18 Summary Basics – REST, ASP.NET Core 2.2 Best practices Security
Testing Documentation Limiting Versioning Monitoring

19 Further reading https://github.com/Microsoft/api-guidelines
Specifikacije HATEOAS – Hypermedia as the Engine of Application State - The ION Hypermedia Type - JSON API Specification - JSON (Hyper-)Schema... - GraphQL APIs - Twitter REST - GitHub REST / v4 GraphQL - Stripe - Twilio - samples and video course

20 Hvala! Pitanja? @miroslavpopovic

21 Thanks to our partners!


Download ppt "Building production-ready APIs with ASP.NET Core 2.2"

Similar presentations


Ads by Google