Skip to main content

provider.go

provider.go - Overview

  1. Overview This file defines a no-op implementation of the web.Web interface, effectively disabling the web component. It provides a factory for creating this no-op web provider.

  2. Detailed Documentation

provider struct

  • Purpose: Represents the no-op web provider.
type provider struct{}

NewFactory function

  • Purpose: Creates a new factory for the no-op web provider.
  • Returns: A factory.ProviderFactory[web.Web, web.Config] that can create instances of the no-op web provider.
func NewFactory() factory.ProviderFactory[web.Web, web.Config]

New function

  • Purpose: Creates a new instance of the no-op web provider.
  • Parameters:
    • ctx (context.Context): The context for the operation.
    • settings (factory.ProviderSettings): The settings for the provider.
    • config (web.Config): The configuration for the web component.
  • Returns: A web.Web interface, which is a pointer to provider struct, and an error. The error is always nil in this implementation.
func New(ctx context.Context, settings factory.ProviderSettings, config web.Config) (web.Web, error)

AddToRouter function

  • Purpose: A no-op implementation of the AddToRouter method. It does nothing.
  • Parameters:
    • router (*mux.Router): The router to add routes to.
  • Returns: An error, which is always nil in this implementation.
func (provider *provider) AddToRouter(router *mux.Router) error

ServeHTTP function

  • Purpose: A no-op implementation of the ServeHTTP method. It does nothing.
  • Parameters:
    • w (http.ResponseWriter): The response writer.
    • r (*http.Request): The HTTP request.
  • Returns: None.
func (provider *provider) ServeHTTP(w http.ResponseWriter, r *http.Request) {}

Include in Getting Started: NO