Skip to main content
[VoyagerEndpoint("weatherForecast/{City}")]
public class WeatherForecastEndpoint
{
public IEnumerable<WeatherForecast> Get(WeatherForecastRequest request)
{
return Enumerable.Range(1, request.Days).Select(index =>
new WeatherForecast
{
City = request.City,
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
TemperatureC = Random.Shared.Next(-20, 55),
}
);
}
}

Define endpoints in their own class throughout your code base and have voyager wire them up for you with it's source generator. There is no performance penalty because the work is done during compilation! No interfaces to implement or base classes to inherit from. Just write the logic and let voyager write the boilerplate.

Request
public class WeatherForecastRequest
{
[FromRoute]
public required string City { get; set; }

[FromQuery]
public int Days { get; set; } = 5;
}

Response
public class WeatherForecast
{
public required string City { get; init; }

public required DateOnly Date { get; init; }

public int TemperatureC { get; init; }

public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}