watermark

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package watermark provides invisible metadata watermarking middleware for Trove. It embeds watermark text into downloaded content by injecting metadata chunks into supported file formats (PNG tEXt, JPEG COM, PDF info dictionary). No image processing libraries are required — only byte-level manipulation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Watermark)

Option configures the Watermark middleware.

func WithSkipTypes

func WithSkipTypes(prefixes ...string) Option

WithSkipTypes sets content type prefixes to skip watermarking.

func WithText

func WithText(text string) Option

WithText sets a static watermark text.

func WithTextFunc

func WithTextFunc(fn TextFunc) Option

WithTextFunc sets a dynamic watermark text function.

func WithTypes

func WithTypes(prefixes ...string) Option

WithTypes sets content type prefixes that should be watermarked. Default: "image/png", "image/jpeg".

type TextFunc

type TextFunc func(ctx context.Context) string

TextFunc generates watermark text dynamically per-request.

type Watermark

type Watermark struct {
	// contains filtered or unexported fields
}

Watermark provides invisible metadata watermarking middleware.

func New

func New(opts ...Option) *Watermark

New creates a new watermark middleware with the given options.

func (*Watermark) Direction

func (w *Watermark) Direction() middleware.Direction

Direction returns Read since watermarking only applies to downloads.

func (*Watermark) Name

func (w *Watermark) Name() string

Name returns the middleware identifier.

func (*Watermark) WrapReader

func (w *Watermark) WrapReader(ctx context.Context, r io.ReadCloser, info *driver.ObjectInfo) (io.ReadCloser, error)

WrapReader wraps a reader to inject watermark metadata into the content on download. Only matching content types are watermarked.

Jump to

Keyboard shortcuts

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