Home Page Icon
Home Page
Table of Contents for
Hands-On RESTful Web Services with ASP.NET Core 3
Close
Hands-On RESTful Web Services with ASP.NET Core 3
by Samuele Resca
Hands-On RESTful Web Services with ASP.NET Core 3
Title Page
Copyright and Credits
Hands-On RESTful Web Services with ASP.NET Core 3
Dedication
About Packt
Why subscribe?
Contributors
About the author
About the reviewer
Packt is searching for authors like you
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Download the color images
Conventions used
Get in touch
Reviews
Section 1: Getting Started
REST 101 and Getting Started with ASP.NET Core
REST
The importance of being REST compliant
REST requirements
Uniform interface
Manipulation of resources through representations
Self-descriptive messages
Hypermedia as the Engine of Application State
Stateless
Client-server separation
Layered system
Richardson maturity model
Introducing ASP.NET Core
The evolution of ASP.NET
The new .NET ecosystem
.NET STANDARD
Why use ASP.NET Core to build RESTful web services?
Preparing your development environment
.NET Core CLI
IDEs and development tools in ASP.NET Core
Summary
Section 2: Overview of ASP.NET Core
Overview of ASP.NET Core
Setting up our .NET Core project
Overview of .csproj
The Program.cs file in detail
Setting up an ASP.NET Core project
The project structure
The Program.cs and Startup.cs files
Overview of controllers 
Summary
Working with the Middleware Pipeline
Introducing middleware
The middleware pipeline in practice
HttpContext in ASP.NET Core
Class-based middleware
Conditional pipeline
Understanding built-in middleware
Summary
Dependency Injection System
Dependency inversion principle
Benefits of dependency injection
Dependency injection in ASP.NET Core
Registering services using the dependency injection container
Registering services conditionally
Constructor injection
Action method injection
Services life cycle
Transient life cycle
Scoped life cycle
Singleton life cycle
Life cycle madness
Injecting services into middleware
Summary
Web Service Stack in ASP.NET Core
What is a controller?
Identifying controllers
Extending controllers
The ApiController attribute
Handling requests using controllers and actions
Creating an in-memory repository
Handling client requests
Handling HTTP methods using actions
Responding to requests
CreateAt response
Updating resources
Partial updating
Deleting resources
Asynchronous processing and acceptance status
Data transfer objects
Implementing request models
Implementing response models
Implementing validation of requests
Custom validation attributes
Summary
Routing System
Overview of the routing system
Conventional routing
Attribute routing
Custom attribute routing
Routing constraints
Custom constraints
Summary
Filter Pipeline
Introduction to filters
Concrete filter implementations
Asynchronous filters
The scope of filters
The use of filters
Life cycle and dependency injection
Filter use cases
Existing entity constraints
Altering exceptions
Summary
Section 3: Building a Real-World RESTful API
Building the Data Access Layer
Setting up the project
Implementing the domain model
Designing entities
Implement entities
Data access using ORMs
Finding the right tool for the job
Implementing a data access layer using EF Core
Defining the repository pattern and unit of work
Connecting our repository to the database
DbContext definition
Implementing the repository 
Transforming entities into a SQL schema
Custom conversions using the Fluent API
Applying the schema definition on the current data context 
Generating a schema for the Artist and Genre entities
Executing migrations
Defining the configuration part
Testing the EF Core repository
Seeding data using DbContext
Initializing the testing class
Implementing a data access layer using Dapper
Creating stored CRUD procedures
Implementing the IItemRepository interface
Summary
Implementing the Domain Logic
Implementing service classes
The service class interface
Implementing the mapping layer
Mapping logic using Automapper
The service class implementation
Testing the service layer
Refactoring testing classes
Implementing the ItemService tests
Implementing request model validation
Testing request model validation
Dependencies registration
Summary
Implementing the RESTful HTTP Layer
Implementing the item controller
Implementing action methods
Testing controllers using the WebApplicationFactory<T> class
Extending the WebApplicationFactory
Testing a controller
Loading test data using xUnit data attributes
Improving the resilience of the API 
Existence check
JSON-customized errors
Implementing pagination
Exposing related entities 
Extending the data access layer
Extending the test coverage 
Extending the IItemRepository interface
Extending the capabilities of the service layer
Improving the validation mechanism
Updating the dependencies in the Startup class
Adding the related controllers
Extending tests for the ArtistController class
A final overview
Summary
Advanced Concepts of Building an API
Implementing the soft delete procedure
Updating the IItemRepository implementation
Implementing delete operations
Implementing HATEOAS 
Enriching our model with HATEOAS data
Implementing HATEOAS in a controller
The asynchronous code in ASP.NET Core
Task definitions
The need for asynchronous code in ASP.NET Core
What's new in ASP.NET Core?
Best practices in asynchronous programming
Don't use async void methods
Use Task.FromResult over Task.Run
Enable cancellation
Asynchronous code in I/O bound operations
Measure response time using middleware
Summary
The Containerization of Services
An introduction to containers
Docker terminology
Using Docker to run the catalog service
Defining environment variables
Defining the Dockerfile
Executing the docker-compose command
Optimizing Docker images
An overview of different Docker images
Multi-stage builds on the catalog service
Summary
Service Ecosystem Patterns
An introduction to the cart service
The theory behind the mediator pattern
The domain model and the data access layer
The ICartRepository Redis implementation
Handlers and routes implementation
Exposing functionalities using CartController
Implementing resilient communication using an HTTP client
Implementing the catalog HTTP client 
Integrating an HTTP client into the cart service
Implementing resilience using Polly.NET
Integrating Polly into ICatalogService
Sharing events using an event bus
Setting up a RabbitMQ instance and publishing an event
Running the cart service using Docker
Summary
Implementing Worker Services Using .NET Core
Introducing worker services
Understanding the worker services life cycle
Hosting models
Implementing a health-checking worker
Project structure overview
Running a worker service on Docker
Consuming the sold-out event
Creating a sold-out handler
Testing the sold-out process
Configuring the background service
Summary
Securing Your Service
Overview of secure communication
Securing data using HTTPS  
Enforcing HTTPS in ASP.NET Core
HTTP/2 on Kestrel
Enabling CORS in ASP.NET Core
Implementing CORS using the middleware approach
Implementing CORS using the attribute approach
Securing APIs with token-based authentication
Implementing token-based authentication
Defining the service layer
Applying authentication on the controller
Storing data using EF Core
Declaring the identity database context
Testing authentication
Summary
Section 4: Advanced Concepts for Building Services
Caching Web Service Responses
Introduction to the HTTP caching system
The HTTP caching specification
Implementing response caching in ASP.NET Core
Implementing a distributed cache
Implementing the IDistributedCache interface
Inject memory cache into the tests
Summary
Logging and Health Checking
Logging in ASP.NET Core
The key characteristics of logging
Implementing the logging part
Exception logging
Verifying logging using Moq
Implementing logging providers
Implementing a custom log provider in tests
Web service health check 
Implementing health checks on databases
Implementing custom health checks
Summary
Deploying Services on Azure
Getting started with Azure
Pushing containers into Azure Container Registry
Creating an Azure Container Registry
Configuring Azure Container Instances
Configuring app services
Creating an app service using a container image
Summary
Documenting Your API Using Swagger
Understanding OpenAPI
Implementing the Swagger project
Implementing OpenAPI in ASP.NET Core services
Understanding ASP.NET Core's conventions
Custom conventions
Summary
Testing Services Using Postman
Overview of Postman
Testing the API using Postman
Using the runner to test the APIs
Importing a collection using OpenAPI
Summary
Other Books You May Enjoy
Leave a review - let other readers know what you think
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Next
Next Chapter
Title Page
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset