Alex's Coding Blog
  • home
  • about
  • projects
  • contact

Blog

GetInfra WebApi Abstractions introduction

  • January 09, 2020
  • by Alexander

I would like to share a GetInfra.WebApi.Abstractions library I'm using in my recent projects. The bits can be found on Github or Nuget package

As havily working on Web API developement I've extracted several accpects in order not to repeat them in each project. In my case, having standard responses among dozens of microservices significally speed up a front-end developement. Maybe can be found useful for your projects as well.

The library includes abstractions for the following:

  • Validation - refers to request validation
  • Responses - several generic classes that can be used as response for api calls.

Validation

Validation is vital part of Web API development, and I as a developer would like to have a flexability to inject custom validators by just implementing ValidatorBase<T>.

Responses

Front-end developers always complian about the responses, especially when it comes to POST, PUT and DELETE methods, To make it universal I came to following base response class:

{
  "errors": [],
  "validationErrors": [],
  "isValid": true,
  "succeeded": true
}

isValid - indicates if there are validation errors.

succeeded - indicates if there are runtime errors. by runtime I mean some try...catch handled exeptions.

errors - array of run time exceptions

validationErrors - array of validation exceptions

Id or newId - depending on implementation, the id property associated with the record.

There are several variations for the response:

  • GenericValResponse<T> - to returns struct with associated Id
  • GenericRefResponse<T> - to returns class as associated Id

Another aspect the libarary is dealing with is list responses, which requires pagination and aggregation.

  • PagedResponse<T> - paginated response
  • PagedResponseWithAggs<T> - paginated response with aggregations

In next posts I will talk about how to create a custom validator, how to use custom regular expressions for your validators and how to form detailed response.

.NET Core

🚀 Turbocharge Your Kubernetes Cluster with my Terraform Kits! 🚀

🌟 Slash deployment time and costs! Discover the ultimate solution for efficient, cost-effective Kubernetes Terraform Kits. Perfect for DevOps enthusiasts looking for a reliable, scalable setup.

Learn More about Terraform Kits for AKS,EKS and GKE

Alexander Lvovich

Solution Architect & Software Developer | Automating & Scaling Infrastructure

💡 Working with Kubernetes, Istio, and DevOps. Got questions? Feel free to reach out!

Share on:

No comments are allowed for this post

Recent Posts

  • Securing Web Services Against Unwanted Traffic with NGINX
  • Optimizing API by Offloading Responsibilities to an API Gateway
  • How to Clean Up Local Branches of Remote Merged Branches
  • Resolving Namespace Overriding in Argo CD with Kustomize
  • Connecting to Gitlab's private Nuget registry
  • Why Istio?

Categories

  • Azure
  • Architecture
  • .NET Core
  • Certification
  • DevOps
  • How-to
  • Azure Functions
  • Serverless
  • Cosmos DB
  • Security
  • Thoughts
  • Kubernetes
  • Istio
© Copyright 2025, Alexander Lvovich. Theme by Colorlib
I use cookies and similar technologies on our website to enhance your browsing experience and analyze website traffic. By clicking "Accept," you consent with my Privacy Policy to the use of these technologies.
Accept