از برنامههای وب ASP.NET Core گرفته تا برنامههای Xamarin، برنامههای ویندوزی و کنسول، اغلب با یک API یکپارچه میشوند. برای این کار، HttpClient گزینهی پیش فرض و بهترین گزینه است. اما استفاده از آن خیلی بیشتر از ارسال درخواست و خواندن پاسخ است. در دوره ویدیویی Using HttpClient to Consume APIs in .NET Core (استفاده از HttpClient برای استفاده از APIها در دات نت کور) موسسه Pluralsight که توسط Kevin Dockx تدریس شده است، نگاهی دقیق به استفاده از HttpClient و HttpClientFactory خواهید انداخت و از ساز و کار داخلی و تعاملات CRUD پایه تا کار با streamها و فشرده سازی را بررسی خواهید کرد. ما همچنین لغو درخواست هایی را که دیگر نیازی به آنها نیست را پوشش خواهیم داد. علاوه بر این، شما یاد خواهید گرفت که چگونه از handlerهای پیام سفارشی برای بهبود قابلیت اطمینان درخواستهای خود و آزمون واحد استفاده کنید. پس از به پایان رساندن این دوره، شما با زیر و بم یکپارچه کردن با APIهای انواع مختلف برنامه ها، آشنا خواهید شد.
Table of Contents:
- Course Overview
- Course Overview
- Understanding Integration with an API Using HttpClient
- Coming Up
- Course Prerequisites
- Frameworks and Tooling
- Supported Platforms, Frameworks, and .NET Standard Versions
- Platforms Implementing .NET Standard 2.0
- Demo: Introducing the Demo Application
- Strategies for Working with DTO Model Classes
- Generating DTO Classes
- Demo: Generating DTO Classes
- Tackling Integration with HttpClient
- Summary
- Handling Common Types of Integration (CRUD)
- Coming Up
- Demo: Getting a Resource
- Working with Headers and Content Negotiation
- Demo: Manipulating Request Headers
- Indicating Preference with the Relative Quality Parameter
- Demo: Indicating Preference with the Relative Quality Parameter
- Demo: Working with HttpRequestMessage Directly
- Demo: Creating a Resource
- Setting Request Headers
- Inspecting Content Types
- Demo: Updating a Resource
- Demo: Deleting a Resource
- Demo: Using Shortcuts
- Summary
- Improving Performance with Partial Updates
- Coming Up
- Introducing JSON Patch
- Demo: Partially Updating Resources
- Demo: Partially Updating Resources with PatchAsync
- Advanced Patch Scenarios
- Summary
- Improving Performance and Memory Use with Streams
- Coming Up
- Advantages of Working with Streams
- Using Streams When Reading Data
- Demo: Using Streams When Reading Data
- Improving Memory Use and Performance with HttpCompletionMode
- Demo: Improving Memory Use and Performance with HttpCompletionMode
- Demo: Improving Code Reuse with an Extension Method
- Demo: Testing Performance Improvements When Reading Data
- Using Streams When Sending Data
- Demo: Using Streams When Sending Data
- Using Streams When Sending and Reading Data
- Demo: Combining Streams When Sending and Reading Data
- Demo: Testing Performance Improvements When Sending Data
- On Streaming, Memory Use, and Performance
- Working with Compression
- Summary
- Supporting Cancellation
- Coming Up
- Why Cancelling Requests Is Important
- CancellationTokenSource and CancellationToken
- Demo: Cancelling a Request
- Demo: CancellationTokenSource Initialization
- Demo: Handling a Cancelled Request
- Dealing with Timeouts
- Summary
- Improving HttpClient Instance Management with HttpClientFactory
- Coming Up
- The Problem with Disposing HttpClient Instances: Part 1
- Demo: The Problem with Disposing HttpClient Instances
- The Problem with Disposing HttpClient Instances: Part 2
- Introducing HttpClientFactory
- Demo: Using HttpClientFactory to Manage HttpClient Instances
- Demo: Using Named Instances and Defaults
- Demo: Configuring the Primary Message Handler
- Demo: Using Typed Instances
- Demo: Using Typed Instances with Type-scoped Configuration
- Demo: Extending Typed Instances with Interaction Methods
- Summary
- Handling Faults and Errors
- Coming Up
- Inspecting Status Codes
- Demo: Inspecting Status Codes
- Inspecting Response Messages
- Demo: Reading out the Response Body When Streaming
- Dealing with All-but-best-practice APIs
- Summary
- Extending HttpClient with Custom HttpMessageHandlers
- Coming Up
- Delegating Handler Pattern
- Implementing a Retry Policy
- Demo: Implementing a Retry Policy
- Implementing a Handler for Dealing with Time-outs
- Demo: Implementing a Handler for Dealing with Time-outs
- Other Use Cases for Delegating Handlers
- Using Polly to Improve Interaction with an API
- Summary
- Unit Testing with HttpClient
- Coming Up
- Unit Testing with HttpClient
- Demo: Implementing a Custom Handler to Allow Unit Testing with HttpClient
- Demo: Writing a Unit Test
- Demo: Improving Mocking with Moq
- Summary