Wisp Documentation

Configuration

Wisp provides flexible configuration options to tailor the framework and your application’s behavior. This page outlines the available configuration settings and how to customize them.


Configuration Sources

By default, Wisp loads configuration from a JSON file named wisp.application.json located in the application root.
You can extend or override this by providing additional configuration sources via the WispHostBuilder.Configure method.

Example:

var builder = new WispHostBuilder()
    .Configure(configBuilder =>
    {
        configBuilder.AddEnvironmentVariables();
        configBuilder.AddJsonFile("appsettings.local.json", optional: true);
    });

Core Configuration Section: Wisp

The framework expects a configuration section named Wisp that maps to the WispConfiguration class. This section contains key runtime settings.

Typical wisp.application.json example:

{
  "Wisp": {
    "Host": "127.0.0.1",
    "Port": 6969,
    "LogLevel": "Information"
  }
}

Key Settings

Setting Type Description Default
Host string IP address to bind the HTTP server to '127.0.0.1'
Port int TCP port for the HTTP server 6969
LogLevel string Logging Level Information

Dependency Injection Configuration

Wisp uses Microsoft's dependency injection (DI) container to manage services.
You can add or modify services during startup using WispHostBuilder.ConfigureServices.

Example:

var builder = new WispHostBuilder()
    .ConfigureServices(services =>
    {
        services.AddSingleton<IMyService, MyService>();
        services.Configure<MySettings>(config.GetSection("MySettings"));
    });

This allows you to:

  • Register your own services
  • Configure options bound to configuration sections
  • Override default framework services if necessary

Logging Configuration

Wisp now supports flexible logging configuration via WispHostBuilder.ConfigureLogging.
By default, it adds a simple console logger.

Example of overriding or extending the default logging setup:

var builder = new WispHostBuilder()
    .ConfigureLogging(logging =>
    {
        logging.SetMinimumLevel(LogLevel.Information);
        logging.AddFilter("MyApp.Namespace", LogLevel.Warning);
        logging.AddDebug();
    });

Behind the scenes, this merges your logging configuration with the defaults, ensuring sensible logging out of the box but giving you full control.


Router and HTTP Server Configuration

  • The router and HTTP server are registered as singletons in DI.
  • The HTTP server listens on the IP and port specified in the configuration (Host and Port).
  • You can replace the HTTP server implementation by overriding the IHttpServer service in ConfigureServices.

Summary of Configuration Extension Points

Extension Point Method Description
Add custom config sources WispHostBuilder.Configure Add JSON, environment variables, etc.
Register or override services WispHostBuilder.ConfigureServices Add your own services or replace defaults
Customize logging WispHostBuilder.ConfigureLogging Add, remove or adjust logging providers and filters
Enable controllers WispApplicationBuilder.UseControllers Registers controllers automatically
Add routes manually WispApplicationBuilder.ConfigureRoutes Define lightweight routes

Additional Notes

  • Configuration is immutable once Build() is called on the host builder.
  • Access configuration values anywhere via DI using IConfiguration or bound options classes.
  • Make sure to keep sensitive settings out of source control and use secure secrets management where appropriate.