This tutorial is about setting up an API Gateway using Ocelot.NET and Consul. The consul integration for Ocelot.NET enables you to fetch registered services and load balance between multiple instances.

Prerequisites

  • Docker Desktop (for running our services and deploying Consul)
    https://www.docker.com/products/docker-desktop
  • IDE of choice, however, I highly recommend Visual Studio because of the simplified docker integration.
  • .NET 5 SDK Installed
  • Basic knowledge about ASP.NET Core and Docker.

Tutorial Content

  1. Deploying Consul using Docker Desktop.
  2. Creating a sample API (microservice 1) and registering it with Consul
  3. Creating the API Gateway using Ocelot.NET and integrating Consul

Completed Tutorial Source can be found on my GitHub

1 Deploying Consul using Docker Desktop


A quick tutorial about creating a CRUD RESTFul API in ASP.Net Core (.NET 5) using MongoDB.

Prerequisites

  • IDE of choice (I’ll be using Jetbrains Rider).
  • Docker Desktop (for deploying MongoDB).
  • Basic knowledge of RESTful API’s, ASPNetCore, and MongoDB
  • AspDotNetCore 3.1 or .NET 5

The entire solution can be found on my Github.

Setting up MongoDB

First, we’ll be deploying a local instance of MongoDB for development purposes. I’ll be using Docker Desktop for this.

In your terminal/command prompt type in the following command:

docker run --name mongodb -v /my/own/datadir:/data/db -p 27017:27017 --restart unless-stopped -d mongo

replace /my/own/datadir with a path on your computer…


5 amazing VSCode extensions that provide lots of quality of life improvements for VSCode. I personally use these extensions myself and I highly recommend them to anyone.

1 indent-rainbow

Indent-rainbow colorizes the indentation in front of your code. It’s a great visual tool that makes it a lot easier to see your indentation.

2 Bracket Pair Colorizer 2

Another visual tool that colorizes your code brackets. I personally can’t live without this, especially when programming in JavaScript.


Image by Christopher Gower at Unsplash

Here are a couple of amazing developer tools that will improve your efficiency and development capabilities.

Disclaimer
This is not a sponsored post, these are the tools I use in my own development workflow.

1 Insomnia Core

Insomnia Core is my preferred HTTP client for testing and calling REST APIs. It’s quite minimalistic and has lots of user-friendly options. It allows you to easily save requests and create different collections.

2 Figma

Figma is a great collaboration tool for designing applications, creating UX designs and wireframes. …


Enabling your secured AspNetCore Web API to accept Firebase tokens is quite simple actually. All you have to do is register the JWTBearer and add the firebase issuer information, detailed steps are below.

This tutorial assumes that you already have an AspNetCore API and a corresponding Frontend that uses Firebase for authentication.

1. Install the JWT Nuget package

2. Register your Authentication Service in Startup.cs

services
.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.Authority = "https://securetoken.google.com/FIREBASE-APP-ID";
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = true,
ValidIssuer = "https://securetoken.google.com/FIREBASE-APP-ID",
ValidateAudience = true,
ValidAudience = "FIREBASE-APP-ID",
ValidateLifetime = true
};
});

Enable Authorization & Authentication in Startup.cs

app.UseAuthentication();
app.UseAuthorization();


An API Gateway is an application/service that is responsible for forwarding/redirecting requests to a downstream service. It is a common practice in Microservice Architectures, however, it also enables you to combine multiple REST APIs provided by different applications into a single HTTP(S) address.

Tutorial Content

  • Creating a simple rest application to act as our downstream application. (Web API Template)
  • Creating the API Gateway which forwards the request to the downstream sample application.

Full Project can be found at https://github.com/dominiquekleeven/medium-apigateway-with-ocelot

Prerequisites

  • IDE of Choice
  • .NET Core 3.1 or .NET 5 SDK (Asp.net Core)

Creating the Sample Application

If you’re using Visual Studio or Rider this should be quite…


First things first: I’d like to share this awesome git repository with lots of NuGet packages and other dotnet components.

1. Fluent Assertions

FluentAssertions allow you to more naturally specify the expected assertion and outcome of a test case/unit test. I highly recommend this to anyone programming and testing in C#/.NET.

Code Example from the Fluent Assertions Documentation:

IEnumerable numbers = new[] { 1, 2, 3 };

numbers.Should().OnlyContain(n => n > 0);
numbers.Should().HaveCount(4, "because we thought we put four items in the collection");

2. AutoMapper

AutoMapper basically enables you to easily convert domain objects to other domain objects based on their property names. I especially…


Photo by Jason Dent on Unsplash

A quick and simple tutorial on hashing passwords using Bcrypt.

This requires the BCrypt.Net-Next NuGet package
https://www.nuget.org/packages/BCrypt.Net-Next/
Quick code example:

EncryptionHelper.cs (Example)

Quick code example:


A simple tutorial on how to create a quick RESTful API in .NET 5

Prerequisites

This guide is for those who are quite new to ASP.NET Core development and have some knowledge about RESTful APIs and C# Development. The main goal of this guide is to quickly explain how to create a REST API and return some data.

Getting Started

Create a new project and choose the ASP.NET Core Web API

Dominique Kleeven

Short Coding Tutorials for .NET & NodeJS

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store