Home

Awesome

Opal on Nuget Opal build Last commit MIT

Opal

A client library for the Gemini and Titan protocols targeting .NET Standard 2.0 and .NET 7

Features

Usage

Install the Nuget package

Install-Package Opal -Version 1.7.6

Create an instance of a client and make requests

// the default behavior is to automatically follow redirects and to persit 
// local and remote certificates to disk
var client = new OpalClient();

var response = await client.SendRequestAsync("gemini.circumlunar.space");

if (response is GemtextResponse gmi)
{
  // the response body may accessed directly...
  await using (var reader = new StreamReader(gmi.Body))
    Console.WriteLine(reader.ReadToEnd());
  
  // ... or as a collection of strongly-typed ILine objects
  foreach (var line in gmi.AsDocument())
  {
    if (line is LinkLine link)
      Console.WriteLine($"Found link to {link.Uri}");
     
    Console.WriteLine(line);
  }
}