37 lines
899 B
Go
37 lines
899 B
Go
|
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
|
||
|
|
||
|
package transport
|
||
|
|
||
|
import (
|
||
|
"io/fs"
|
||
|
"decl/internal/identifier"
|
||
|
"net/url"
|
||
|
"path/filepath"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
type HTTPFileInfo struct {
|
||
|
URI identifier.ID
|
||
|
parsedURI *url.URL
|
||
|
ContentLength int64
|
||
|
LastModified time.Time
|
||
|
ContentType string
|
||
|
Collection bool
|
||
|
}
|
||
|
|
||
|
func NewHTTPFileInfo(uri string) (h *HTTPFileInfo) {
|
||
|
h = &HTTPFileInfo{ URI: identifier.ID(uri) }
|
||
|
h.parsedURI = h.URI.Parse()
|
||
|
if h.parsedURI == nil {
|
||
|
return nil
|
||
|
}
|
||
|
return
|
||
|
}
|
||
|
|
||
|
func (h *HTTPFileInfo) Size() int64 { return h.ContentLength }
|
||
|
func (h *HTTPFileInfo) Name() string { return filepath.Base(h.parsedURI.Path) }
|
||
|
func (h *HTTPFileInfo) Mode() fs.FileMode { return 0777 }
|
||
|
func (h *HTTPFileInfo) ModTime() time.Time { return h.LastModified }
|
||
|
func (h *HTTPFileInfo) IsDir() bool { return h.Collection }
|
||
|
func (h *HTTPFileInfo) Sys() any { return any(h) }
|