Documentation
¶
Overview ¶
Copyright © 2024, 2025 M.Watermann, 10247 Berlin, Germany
All rights reserved EMail : <support@mwat.de>
Package `reprox` implements a hostname based reverse proxy server.
Copyright © 2024. 2025 M.Watermann, 10247 Berlin, Germany
All rights reserved EMail : <support@mwat.de>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
You should have received a copy of the GNU General Public License along with this program. If not, see the [GNU General Public License](http://www.gnu.org/licenses/gpl.html) for details.
Copyright © 2024, 2025 M.Watermann, 10247 Berlin, Germany
All rights reserved EMail : <support@mwat.de>
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfDir ¶ added in v0.6.0
func ConfDir() (rDir string)
`ConfDir()` returns the directory path where the configuration files for the running application should be stored.
If the current user is root, the directory is "/etc/<program_name>". Otherwise, it is "~/.config/<program_name>".
If the directory does not yet exist, it is created with permissions 0750.
Returns:
- `string`: The directory path to use for application-specific configuration files.
NOTE: This function is Linux-specific and considers only the "happy path" (i.e. no proper error handling).
func LoadConfig ¶ added in v0.6.0
`LoadConfig()` loads the configuration from a JSON file.
Parameters:
- `aFilename`: The path/name of the JSON configuration file.
Returns:
- `*tProxyConfig`: A pointer to the loaded configuration.
- `error`: An error, if the configuration could not be loaded.
func WatchConfigFile ¶ added in v0.6.0
func WatchConfigFile(aCtx context.Context, aPc *tProxyConfig, aFilename string, aInterval time.Duration)
`WatchConfigFile()` monitors a configuration file for changes and reloads it when modified.
The function runs until the context is cancelled.
Parameters:
- `aCtx`: Context for cancellation.
- `aPc`: The proxy configuration to update.
- `aFilename`: Path/name of the configuration file to watch.
- `aInterval`: How often to check for changes.
Types ¶
type IConnCloser ¶ added in v0.9.0
type IConnCloser interface {
CloseIdleConnections()
}
`IConnCloser` is an interface for types that can close idle connections.
type TProxyHandler ¶
type TProxyHandler struct {
// contains filtered or unexported fields
}
`TProxyHandler` is the page handler for proxy requests.
func New ¶ added in v0.8.4
func New(aConfig *tProxyConfig) *TProxyHandler
`New()` creates a new instance of `TProxyHandler` with the provided configuration data.
Parameters:
- `aConfig`: A pointer to the server configuration.
Returns:
- `*TProxyHandler`: A pointer to a new instance of TProxyHandler.
func (*TProxyHandler) CloseIdleConnections ¶ added in v0.9.0
func (ph *TProxyHandler) CloseIdleConnections()
`CloseIdleConnections()` closes all idle connections in the proxy's transport layer.
func (*TProxyHandler) ServeHTTP ¶
func (ph *TProxyHandler) ServeHTTP(aWriter http.ResponseWriter, aRequest *http.Request)
`ServeHTTP()` is the main entry point for the reverse proxy server. It handles incoming HTTP requests and forwards them to the appropriate backend server.
Parameters:
- `aWriter`: The `ResponseWriter` to write HTTP response headers and body.
- `aRequest`: The request containing all the details of the incoming HTTP request.