Documentation
¶
Overview ¶
Package httpserver will contain the main httpserver functionality of goshs
Index ¶
- func GenerateQRCode(uri string) string
- func GenerateToken() string
- func GetClientIP(r *http.Request, whitelist *Whitelist) string
- type BreadcrumbPart
- type ClipEntry
- type CustomMux
- type DownloadEntry
- type FileItem
- type FileServer
- func (files *FileServer) AddCertAuth(server *http.Server)
- func (fs *FileServer) BasicAuthMiddleware(next http.Handler) http.Handler
- func (fs *FileServer) CreateShareHandler(w http.ResponseWriter, r *http.Request)
- func (fs *FileServer) DeleteShareHandler(w http.ResponseWriter, r *http.Request)
- func (fs *FileServer) IPWhitelistMiddleware(next http.Handler) http.Handler
- func (fs *FileServer) InvisibleBasicAuthMiddleware(next http.Handler) http.Handler
- func (files *FileServer) PrintEmbeddedFiles()
- func (fs *FileServer) ServerHeaderMiddleware(next http.Handler) http.Handler
- func (fs *FileServer) SetupMux(mux *CustomMux, what string) string
- func (fs *FileServer) ShareHandler(w http.ResponseWriter, r *http.Request)
- func (fs *FileServer) Start(what string)
- func (fs *FileServer) StartListener(server *http.Server, what string, listener net.Listener)
- type Middleware
- type SharedLink
- type UIData
- type Whitelist
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateQRCode ¶
func GenerateToken ¶
func GenerateToken() string
Types ¶
type BreadcrumbPart ¶
BreadcrumbPart is a single segment of the path breadcrumb.
type CustomMux ¶
type CustomMux struct {
// contains filtered or unexported fields
}
func (*CustomMux) Handle ¶
Handle registers a new route with the CustomMux, applying all middleware in reverse order.
func (*CustomMux) HandleFunc ¶
func (cm *CustomMux) HandleFunc(pattern string, handler http.HandlerFunc)
HandleFunc registers a new route with the CustomMux, applying all middleware in reverse order.
func (*CustomMux) ServeHTTP ¶
func (cm *CustomMux) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements the http.Handler interface, allowing the CustomMux to be used as an HTTP server.
func (*CustomMux) Use ¶
func (cm *CustomMux) Use(mw Middleware)
Use simulates the behavior of http.ServeMux.Use, allowing you to add middleware to the CustomMux.
type DownloadEntry ¶
type FileItem ¶
type FileItem struct {
RelPath string
Name string
IsDir bool
Size string // human-readable, e.g. "1.4 MB"
SizeRaw int64 // bytes, used for JS sorting
LastMod string // formatted date string
LastModRaw int64 // unix timestamp, used for JS sorting
Extension string // lowercase with dot, e.g. ".go"
QRCode string
Auth bool
}
FileItem represents one row in the file listing table.
type FileServer ¶
type FileServer struct {
IP string
Port int
CLI bool
WebdavPort int
Webroot string
UploadFolder string
SSL bool
SelfSigned bool
LetsEncrypt bool
MyKey string
MyCert string
MyP12 string
P12NoPass bool
User string
Pass string
CACert string
DropUser string
Version string
Fingerprint256 string
Fingerprint1 string
UploadOnly bool
ReadOnly bool
NoClipboard bool
NoDelete bool
Silent bool
Invisible bool
Embedded bool
Verbose bool
Webhook webhook.Webhook
Hub *ws.Hub
Clipboard *clipboard.Clipboard
Whitelist *Whitelist
Tunnel bool
TunnelURL string
Options *options.Options
CSRFToken string
}
FileServer holds the fileserver information
func NewHttpServer ¶
func (*FileServer) AddCertAuth ¶
func (files *FileServer) AddCertAuth(server *http.Server)
func (*FileServer) BasicAuthMiddleware ¶
func (fs *FileServer) BasicAuthMiddleware(next http.Handler) http.Handler
BasicAuthMiddleware is a middleware to handle the basic auth
func (*FileServer) CreateShareHandler ¶
func (fs *FileServer) CreateShareHandler(w http.ResponseWriter, r *http.Request)
func (*FileServer) DeleteShareHandler ¶
func (fs *FileServer) DeleteShareHandler(w http.ResponseWriter, r *http.Request)
func (*FileServer) IPWhitelistMiddleware ¶
func (fs *FileServer) IPWhitelistMiddleware(next http.Handler) http.Handler
IPWhitelistMiddleware checks if the request's IP is in the whitelist
func (*FileServer) InvisibleBasicAuthMiddleware ¶
func (fs *FileServer) InvisibleBasicAuthMiddleware(next http.Handler) http.Handler
InvisibleBasicAuthMiddleware is a middleware to handle basic auth in invisible mode
func (*FileServer) PrintEmbeddedFiles ¶
func (files *FileServer) PrintEmbeddedFiles()
func (*FileServer) ServerHeaderMiddleware ¶
func (fs *FileServer) ServerHeaderMiddleware(next http.Handler) http.Handler
ServerHeaderMiddleware sets a custom Server header for all responses
func (*FileServer) ShareHandler ¶
func (fs *FileServer) ShareHandler(w http.ResponseWriter, r *http.Request)
func (*FileServer) Start ¶
func (fs *FileServer) Start(what string)
Start will start the file server
func (*FileServer) StartListener ¶
type SharedLink ¶
type SharedLink struct {
}
type UIData ¶
type UIData struct {
// Meta
GoshsVersion string
// Current path
AbsPath string
BreadcrumbParts []BreadcrumbPart
Subdirectory bool
QRCode string
// Feature flags (controls which tabs/buttons appear)
ReadOnly bool
UploadOnly bool
NoClipboard bool
NoDelete bool
CLI bool
Embedded bool
// File listing
Items []FileItem
// Embedded files
EmbeddedItems []FileItem
// Clipboard entries (pre-loaded from server state)
Clipboard []ClipEntry
// CSRF token embedded into the page for JS to read
CSRFToken string
}
UIData is the struct passed to index.html on every page render. Map your existing FileServer fields onto this when calling renderIndex.