mirror of
https://github.com/yusing/godoxy.git
synced 2026-01-11 14:20:32 +01:00
Split the monolithic `internal/homepage` icons functionality into a structured package hierarchy: - `internal/homepage/icons/` - Core types (URL, Key, Meta, Provider, Source, Variant) - `internal/homepage/icons/fetch/` - Icon fetching logic (content.go, fetch.go, route.go) - `internal/homepage/icons/list/` - Icon listing and search (list_icons.go, list_icons_test.go) Moved icon-related code from `internal/homepage/`: - `icon_url.go` → `icons/url.go` (+ url_test.go) - `content.go` → `icons/fetch/content.go` - `route.go` → `icons/fetch/route.go` - `list_icons.go` → `icons/list/list_icons.go` (+ list_icons_test.go) Updated all consumers to use the new package structure: - `cmd/main.go` - `internal/api/v1/favicon.go` - `internal/api/v1/icons.go` - `internal/idlewatcher/handle_http.go` - `internal/route/route.go`
38 lines
584 B
Go
38 lines
584 B
Go
package iconfetch
|
|
|
|
import (
|
|
"bufio"
|
|
"errors"
|
|
"net"
|
|
"net/http"
|
|
)
|
|
|
|
type content struct {
|
|
header http.Header
|
|
data []byte
|
|
status int
|
|
}
|
|
|
|
func newContent() *content {
|
|
return &content{
|
|
header: make(http.Header),
|
|
}
|
|
}
|
|
|
|
func (c *content) Header() http.Header {
|
|
return c.header
|
|
}
|
|
|
|
func (c *content) Write(data []byte) (int, error) {
|
|
c.data = append(c.data, data...)
|
|
return len(data), nil
|
|
}
|
|
|
|
func (c *content) WriteHeader(statusCode int) {
|
|
c.status = statusCode
|
|
}
|
|
|
|
func (c *content) Hijack() (net.Conn, *bufio.ReadWriter, error) {
|
|
return nil, nil, errors.New("not supported")
|
|
}
|