{"modulePath":"github.com/benthosdev/benthos/v4","version":"v4.19.0","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package httpserver\n\n## Functions\n\n```go\nfunc BasicAuthFieldSpec() docs.FieldSpec\n```\nBasicAuthFieldSpec returns the spec for an HTTP BasicAuth component.\n\n```go\nfunc ServerCORSFieldSpec() docs.FieldSpec\n```\nServerCORSFieldSpec returns a field spec for an http server CORS component.\n\n## Types\n\n```go\ntype BasicAuthConfig struct {\n\tEnabled      bool   `json:\"enabled\" yaml:\"enabled\"`\n\tUsername     string `json:\"username\" yaml:\"username\"`\n\tPasswordHash string `json:\"password_hash\" yaml:\"password_hash\"`\n\tRealm        string `json:\"realm\" yaml:\"realm\"`\n\tAlgorithm    string `json:\"algorithm\" yaml:\"algorithm\"`\n\tSalt         string `json:\"salt\" yaml:\"salt\"`\n}\n```\nBasicAuthConfig contains struct based fields for basic authentication.\n\n```go\nfunc NewBasicAuthConfig() BasicAuthConfig\n```\nNewBasicAuthConfig returns a BasicAuthConfig with default values.\n\n```go\nfunc (b BasicAuthConfig) Validate() error\n```\nValidate confirms that the BasicAuth is properly configured.\n\n```go\nfunc (b BasicAuthConfig) WrapHandler(next http.HandlerFunc) http.HandlerFunc\n```\nWrapHandler wraps the provided HTTP handler with middleware that enforces BasicAuth if it's enabled.\n\n```go\ntype CORSConfig struct {\n\tEnabled        bool     `json:\"enabled\" yaml:\"enabled\"`\n\tAllowedOrigins []string `json:\"allowed_origins\" yaml:\"allowed_origins\"`\n}\n```\nCORSConfig contains struct configuration for allowing CORS headers.\n\n```go\nfunc NewServerCORSConfig() CORSConfig\n```\nNewServerCORSConfig returns a new server CORS config with default fields.\n\n```go\nfunc (conf CORSConfig) WrapHandler(handler http.Handler) (http.Handler, error)\n```\nWrapHandler wraps a provided HTTP handler with middleware that enables CORS requests (when configured).\n\n","path":"github.com/benthosdev/benthos/v4/internal/httpserver","name":"httpserver","synopsis":"","isRedistributable":true}
