netimage

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

README

ui/netimage

网络图片,可选模块。引入后 Image、Avatar、Attachment 的 Source、Markdown 图片和图片磁盘缓存都能加载 http://、https:// 地址。

import _ "github.com/dyike/keel/ui/netimage"
  • 为什么单独成包:它用 net/http,连带 TLS 等加密库约 4 MB,只显示本地图片的应用不必带上。不引入时本地路径、file:// 和 data URL 照常工作,网络地址返回 core.ErrNoImageFetcher,错误信息里写明要引入的包。
  • 依赖:ui/core(实现 core.ImageFetcher 并在 init 里 core.SetImageFetcher)和标准库 net/http。
  • netimage.Client 是使用的 HTTP 客户端,默认 http.DefaultClient,可以在第一次请求前换成带代理、超时或鉴权的客户端。

要用别的网络栈,实现 core.ImageFetcher 并调用 core.SetImageFetcher。

Documentation

Overview

Package netimage lets Keel load images from http and https URLs. Import it for its side effect where the app shows network images:

import _ "github.com/dyike/keel/ui/netimage"

It is separate because net/http and TLS add about 4 MB to a binary that may never fetch an image.

Index

Constants

This section is empty.

Variables

Client is the HTTP client used for images, http.DefaultClient unless set before the first request.

Functions

func Fetch

func Fetch(ctx context.Context, url string, header map[string]string) (int, map[string]string, io.ReadCloser, error)

Fetch is the core.ImageFetcher this package installs.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL