jx/internal/transport/httpfileinfo.go
Matthew Rich eaaf0f8931
All checks were successful
Lint / golangci-lint (push) Successful in 10m38s
Declarative Tests / test (push) Successful in 38s
collect resource/doc errors and add to result. Add readwritecloser support for HTTP transport reading response data
2024-10-02 20:26:02 +00:00

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) }