Understanding Internet Protocols: HTTP, HTTPS, TCP, UDP, and More

Understanding Internet Protocols: HTTP, HTTPS, TCP, UDP, and More Websites and applications communicate using different protocols, which are standardized methods for transferring data over a network. These protocols define how data is sent, received, and interpreted between systems. Below, we explore the most widely used protocols and their key features. HTTP (Hypertext Transfer Protocol) HTTP is the original protocol used for web communication. It enables the transfer of hypertext documents and allows users to interact with websites. ...

March 15, 2025 · 3 min · Taner

Updated Implementation Using `System.Text.Json`

Updated Implementation Using System.Text.Json using System; using System.Text.Json; using System.Text.Json.Serialization; public abstract class MessageEnvelope<T> { // Properties remain immutable public string EventType { get; private init; } public string SourceService { get; private init; } public DateTime Timestamp { get; private init; } public Guid TraceId { get; private init; } public T Payload { get; private init; } // Private constructor for builder use only private MessageEnvelope() { } public static Builder CreateBuilder() => new Builder(); // Serialization to JSON public string ToJson() { var options = new JsonSerializerOptions { WriteIndented = true // Makes the output JSON easier to read }; return JsonSerializer.Serialize(this, options); } // Deserialization from JSON public static MessageEnvelope<T> FromJson(string json) { var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true // Handles case differences in JSON properties }; return JsonSerializer.Deserialize<ConcreteMessageEnvelope>(json, options); } // Concrete implementation example for proper deserialization private class ConcreteMessageEnvelope : MessageEnvelope<T> { } public class Builder { private readonly MessageEnvelope<T> _envelope = new ConcreteMessageEnvelope(); public Builder WithEventType(string eventType) { _envelope.EventType = eventType; return this; } public Builder WithSourceService(string sourceService) { _envelope.SourceService = sourceService; return this; } public Builder WithPayload(T payload) { _envelope.Payload = payload; return this; } public Builder WithTimestamp(DateTime timestamp) { _envelope.Timestamp = timestamp; return this; } public Builder WithTraceId(Guid traceId) { _envelope.TraceId = traceId; return this; } public MessageEnvelope<T> Build() { _envelope.Timestamp = _envelope.Timestamp == default ? DateTime.UtcNow : _envelope.Timestamp; _envelope.TraceId = _envelope.TraceId == default ? Guid.NewGuid() : _envelope.TraceId; return _envelope; } } } Example Usage 1. Serialize a MessageEnvelope to JSON var envelope = MessageEnvelope<Reservation> .CreateBuilder() .WithEventType("ReservationExpiry") .WithSourceService("ReservationService") .WithPayload(new Reservation { ReservationId = "res-001", SlotId = "slot-123", ExpiryTime = DateTime.UtcNow }) .Build(); string serialized = envelope.ToJson(); Console.WriteLine($"Serialized Envelope:\n{serialized}"); 2. Deserialize a JSON String to MessageEnvelope string json = "{\"EventType\":\"ReservationExpiry\",\"SourceService\":\"ReservationService\",\"Timestamp\":\"2025-03-25T17:00:00Z\",\"TraceId\":\"8a1db2c2-ec3e-45f7-a3eb-bd9dfb351245\",\"Payload\":{\"ReservationId\":\"res-001\",\"SlotId\":\"slot-123\",\"ExpiryTime\":\"2025-03-25T17:00:00Z\"}}"; var deserializedEnvelope = MessageEnvelope<Reservation>.FromJson(json); Console.WriteLine($"Deserialized EventType: {deserializedEnvelope.EventType}"); Console.WriteLine($"Deserialized Reservation ID: {deserializedEnvelope.Payload.ReservationId}"); Benefits of Serialization Portability: You can transmit envelopes as JSON over APIs, message brokers, or store them in databases. Interoperability: Many systems can parse JSON, making serialized envelopes easy to integrate across platforms. Flexibility: Deserialization lets you reconstruct envelopes when receiving messages. Advantages of System.Text.Json Performance: Faster than Newtonsoft.Json, especially for large-scale applications. Built-in Support: No need for external dependencies; it’s natively part of .NET Core and .NET 5+. Configuration Options: Flexible JSON options like camel casing, case insensitivity, and indented formatting.

March 15, 2025 · 2 min · Taner

Integrating Mermaid Diagrams into Your Hugo Site

Integrating Mermaid Diagrams into Your Hugo Site Mermaid is a powerful JavaScript-based diagramming and charting tool that lets you create diagrams using text and code, making them version-controllable and maintainable. By integrating Mermaid with your Hugo site, you can create flowcharts, sequence diagrams, class diagrams, and more, all within your Markdown content. Why Use Mermaid with Hugo? Simple Syntax: Create diagrams using an easy-to-learn markdown-like syntax Maintainable: Store diagrams as text, making them version-controllable Dynamic: Diagrams render in the browser, enabling interactive features Adaptable: Your diagrams will automatically match your site’s theme Let’s walk through the steps to add Mermaid support to your Hugo site. ...

March 10, 2025 · 3 min · Taner

Windows → Debian: Manual SSH Key Setup

🪟 Windows → Debian: Manual SSH Key Setup ✅ 1. Generate an SSH key on Windows If you haven’t already, open PowerShell or Git Bash and run: ssh-keygen -t ed25519 -C "[email protected]" Press Enter to accept the default location (C:\Users\<YourName>\.ssh\id_ed25519). Optionally set a passphrase for extra security, or leave it empty for passwordless login. 📋 2. Copy the public key to the Debian server Option A: Pipe the public key over SSH (PowerShell) This method appends your public key directly into the remote user’s authorized_keys file: ...

March 10, 2025 · 2 min · Taner

Alpine Linux Web Server Options: Fast and Efficient Choices

Alpine Linux Web Server Options: Fast and Efficient Choices For a fast and efficient web server on Alpine Linux, you have several great options. Here are a few popular choices: 1. Nginx Known for its high performance and stability, Nginx is a versatile web server that can also function as a reverse proxy and load balancer. It’s highly efficient in handling many concurrent connections, making it suitable for high-traffic websites and applications. ...

February 23, 2025 · 2 min · TC

How to Access Your Hugo Site Externally on Alpine Linux

How to Access Your Hugo Site Externally on Alpine Linux To access your Hugo site externally on Alpine Linux, follow these steps to ensure your server is properly set up and accessible: 1. Install Required Dependencies sudo apk add curl git nginx 2. Download Hugo HUGO_VERSION=0.143.1 TEMP=$(mktemp -d) wget -O "${TEMP}/hugo.tar.gz" "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz" 3. Extract and Install Hugo sudo tar -xf "${TEMP}/hugo.tar.gz" -C /usr/bin sudo apk add --update libc6-compat libstdc++ 4. Verify Installation hugo version 5. Build Your Hugo Site Navigate to your Hugo site’s directory and run: ...

February 23, 2025 · 2 min · TC

How to Add Menu Items to Your Hugo Site

How to Add Menu Items to Your Hugo Site To add menu items to your Hugo site, you’ll need to modify your site’s configuration file and the front matter of your content files. Here’s how you can do it: Step 1: Update the Configuration File Edit your site’s configuration file (config.toml, config.yaml, or config.json). I’ll use config.toml as an example: # config.toml baseURL = "http://example.org/" languageCode = "en-us" title = "My Hugo Site" theme = "your-theme" [menu] [[menu.main]] identifier = "home" name = "Home" url = "/" weight = 1 [[menu.main]] identifier = "about" name = "About" url = "/about/" weight = 2 [[menu.main]] identifier = "blog" name = "Blog" url = "/posts/" weight = 3 identifier: Unique identifier for the menu item. name: Display name of the menu item. url: URL or path to the page. weight: Determines the order of the menu items (lower weights appear first). Step 2: Update the Front Matter of Content Files Add the menu definition to the front matter of your content files. For example, in a markdown file: ...

February 23, 2025 · 3 min · TC

How to Add Pictures to Your Hugo Page

How to Add Pictures to Your Hugo Page Adding pictures to your Hugo page is quite straightforward. Here’s a step-by-step guide to help you do that: Step 1: Add the Image to the Static Directory Place the image you want to use in the static directory of your Hugo site. The static directory is intended for static assets like images, CSS files, and JavaScript files. For example, if your image is named example.jpg, you can place it in the static/images directory: ...

February 23, 2025 · 2 min · TC

How to Configure Traefik to Serve Your Hugo Site on Alpine Linux

How to Configure Traefik to Serve Your Hugo Site on Alpine Linux You can configure Traefik to serve your Hugo site. Here’s a step-by-step guide to set this up: 1. Install Docker and Docker Compose If Docker and Docker Compose are not already installed on your Alpine Linux VM, you can install them with the following commands: sudo apk add docker sudo apk add docker-compose 2. Create a Docker Compose File Create a docker-compose.yml file for your Hugo site. This file will define your Hugo service and the Traefik reverse proxy. Here is an example configuration: ...

February 23, 2025 · 2 min · TC

How to Install and Use Nginx on Alpine Linux

How to Install and Use Nginx on Alpine Linux Installing and using the Nginx web server on Alpine Linux is straightforward. Follow these steps to get Nginx up and running on your system: 1. Update the Package Repository First, update your package repository to ensure you have the latest package information: apk update apk upgrade 2. Install Nginx Install Nginx using the apk package manager: apk add nginx 3. Start Nginx Start the Nginx service: ...

February 23, 2025 · 1 min · TC