{"modulePath":"github.com/patrickhener/goshs/v2","version":"v2.0.0","isLatest":true,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package httpserver\n\nPackage httpserver will contain the main httpserver functionality of goshs\n\n## Functions\n\n```go\nfunc GenerateQRCode(uri string) string\n```\n\n```go\nfunc GenerateToken() string\n```\n\n```go\nfunc GetClientIP(r *http.Request, whitelist *Whitelist) string\n```\n\n## Types\n\n```go\ntype BreadcrumbPart struct {\n\tName string\n\tPath string\n}\n```\nBreadcrumbPart is a single segment of the path breadcrumb.\n\n```go\ntype ClipEntry struct {\n\tID      int\n\tContent string\n\tTime    string\n}\n```\nClipEntry is a single clipboard entry rendered server-side.\n\n```go\ntype CustomMux struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewCustomMux() *CustomMux\n```\nNewCustomMux creates a new CustomMux instance.\n\n```go\nfunc (cm *CustomMux) Handle(pattern string, handler http.Handler)\n```\nHandle registers a new route with the CustomMux, applying all middleware in reverse order.\n\n```go\nfunc (cm *CustomMux) HandleFunc(pattern string, handler http.HandlerFunc)\n```\nHandleFunc registers a new route with the CustomMux, applying all middleware in reverse order.\n\n```go\nfunc (cm *CustomMux) ServeHTTP(w http.ResponseWriter, r *http.Request)\n```\nServeHTTP implements the http.Handler interface, allowing the CustomMux to be used as an HTTP server.\n\n```go\nfunc (cm *CustomMux) Use(mw Middleware)\n```\nUse simulates the behavior of http.ServeMux.Use, allowing you to add middleware to the CustomMux.\n\n```go\ntype DownloadEntry struct {\n\tDownloadURL string\n\tQRCode      template.URL\n}\n```\n\n```go\ntype FileItem struct {\n\tRelPath    string\n\tName       string\n\tIsDir      bool\n\tSize       string // human-readable, e.g. \"1.4 MB\"\n\tSizeRaw    int64  // bytes, used for JS sorting\n\tLastMod    string // formatted date string\n\tLastModRaw int64  // unix timestamp, used for JS sorting\n\tExtension  string // lowercase with dot, e.g. \".go\"\n\tQRCode     string\n\tAuth       bool\n}\n```\nFileItem represents one row in the file listing table.\n\n```go\ntype FileServer struct {\n\tIP             string\n\tPort           int\n\tCLI            bool\n\tWebdavPort     int\n\tWebroot        string\n\tUploadFolder   string\n\tSSL            bool\n\tSelfSigned     bool\n\tLetsEncrypt    bool\n\tMyKey          string\n\tMyCert         string\n\tMyP12          string\n\tP12NoPass      bool\n\tUser           string\n\tPass           string\n\tCACert         string\n\tDropUser       string\n\tVersion        string\n\tFingerprint256 string\n\tFingerprint1   string\n\tUploadOnly     bool\n\tReadOnly       bool\n\tNoClipboard    bool\n\tNoDelete       bool\n\tSilent         bool\n\tInvisible      bool\n\tEmbedded       bool\n\tVerbose        bool\n\tWebhook        webhook.Webhook\n\tHub            *ws.Hub\n\tClipboard      *clipboard.Clipboard\n\tWhitelist      *Whitelist\n\tSharedLinks    map[string]SharedLink\n\tTunnel         bool\n\tTunnelURL      string\n\tOptions        *options.Options\n\tCSRFToken      string\n}\n```\nFileServer holds the fileserver information\n\n```go\nfunc NewHttpServer(opts *options.Options, hub *ws.Hub, clip *clipboard.Clipboard, wl *Whitelist, wh webhook.Webhook) *FileServer\n```\n\n```go\nfunc (files *FileServer) AddCertAuth(server *http.Server)\n```\n\n```go\nfunc (fs *FileServer) BasicAuthMiddleware(next http.Handler) http.Handler\n```\nBasicAuthMiddleware is a middleware to handle the basic auth\n\n```go\nfunc (fs *FileServer) CreateShareHandler(w http.ResponseWriter, r *http.Request)\n```\n\n```go\nfunc (fs *FileServer) DeleteShareHandler(w http.ResponseWriter, r *http.Request)\n```\n\n```go\nfunc (fs *FileServer) IPWhitelistMiddleware(next http.Handler) http.Handler\n```\nIPWhitelistMiddleware checks if the request's IP is in the whitelist\n\n```go\nfunc (fs *FileServer) InvisibleBasicAuthMiddleware(next http.Handler) http.Handler\n```\nInvisibleBasicAuthMiddleware is a middleware to handle basic auth in invisible mode\n\n```go\nfunc (files *FileServer) PrintEmbeddedFiles()\n```\n\n```go\nfunc (fs *FileServer) ServerHeaderMiddleware(next http.Handler) http.Handler\n```\nServerHeaderMiddleware sets a custom Server header for all responses\n\n```go\nfunc (fs *FileServer) SetupMux(mux *CustomMux, what string) string\n```\n\n```go\nfunc (fs *FileServer) ShareHandler(w http.ResponseWriter, r *http.Request)\n```\n\n```go\nfunc (fs *FileServer) Start(what string)\n```\nStart will start the file server\n\n```go\nfunc (fs *FileServer) StartListener(server *http.Server, what string, listener net.Listener)\n```\n\n```go\ntype Middleware func(http.Handler) http.Handler\n```\n\n```go\ntype SharedLink struct {\n\tFilePath        string\n\tIsDir           bool\n\tExpires         time.Time\n\tDownloadLimit   int\n\tDownloaded      int\n\tDownloadEntries []DownloadEntry\n}\n```\n\n```go\ntype UIData struct {\n\t// Meta\n\tGoshsVersion string\n\n\t// Current path\n\tAbsPath         string\n\tBreadcrumbParts []BreadcrumbPart\n\tSubdirectory    bool\n\tQRCode          string\n\tSharedLinks     map[string]SharedLink\n\n\t// Feature flags (controls which tabs/buttons appear)\n\tReadOnly    bool\n\tUploadOnly  bool\n\tNoClipboard bool\n\tNoDelete    bool\n\tCLI         bool\n\tEmbedded    bool\n\n\t// File listing\n\tItems []FileItem\n\n\t// Embedded files\n\tEmbeddedItems []FileItem\n\n\t// Clipboard entries (pre-loaded from server state)\n\tClipboard []ClipEntry\n\n\t// CSRF token embedded into the page for JS to read\n\tCSRFToken string\n}\n```\nUIData is the struct passed to index.html on every page render. Map your existing FileServer fields onto this when calling renderIndex.\n\n```go\ntype Whitelist struct {\n\tNetworks       []*net.IPNet\n\tTrustedProxies []*net.IPNet\n\tEnabled        bool\n}\n```\n\n```go\nfunc NewIPWhitelist(cidrs string, enabled bool, trustedProxies string) (*Whitelist, error)\n```\n\n```go\nfunc (w *Whitelist) IsAllowed(ipStr string) bool\n```\n\n```go\nfunc (w *Whitelist) IsTrustedProxy(ipStr string) bool\n```\n\n","path":"github.com/patrickhener/goshs/v2/httpserver","name":"httpserver","synopsis":"Package httpserver will contain the main httpserver functionality of goshs","isRedistributable":true}
