mocksite

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package mocksite: HTTP test hosting with HTML page serving Provides simple HTTP hosting using Gin framework when testing pages Enables dynamic page registration and serving with in-process storage Supports rapid prototyping and testing of HTML content with URL generation

mocksite: 具有 HTML 页面服务的 HTTP 测试托管 使用 Gin 框架提供简单的 HTTP 服务用于页面测试 启用动态页面注册和进程内存储服务 支持 HTML 内容的快速原型制作和测试,具有 URL 生成功能

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PageSite

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

PageSite provides HTTP test capabilities with dynamic page hosting Manages temp HTTP instance and in-process page storage when testing Enables rapid webpage content serving with unique URL generation

PageSite 提供动态页面托管的 HTTP 测试功能 管理临时 HTTP 实例和进程内页面存储以供测试 启用具有唯一 URL 生成的快速网页内容服务

func NewPageSite

func NewPageSite() *PageSite

NewPageSite creates HTTP test instance with Gin framework integration Initializes temp HTTP with dynamic page routing capabilities Returns PageSite instance configured and set to host webpages and generate URLs

NewPageSite 创建与 Gin 框架集成的 HTTP 测试实例 初始化具有动态页面路由功能的临时 HTTP 返回已配置的 PageSite 实例,可用于网页托管和 URL 生成

func (*PageSite) Close

func (s *PageSite) Close()

Close terminates HTTP test instance and releases resources Stops the temp HTTP and cleans up network connections Should be invoked when testing is done

Close 终止 HTTP 测试实例并释放资源 停止临时 HTTP 并清理网络连接 应在测试完成时调用

func (s *PageSite) GetLink(path string) string

GetLink generates complete URL using specified path on test instance Constructs HTTP URL using test base address and provided path Path must not contain slash characters to ensure safe routing

GetLink 使用测试实例上的指定路径生成完整 URL 使用测试基地址和提供的路径构建 HTTP URL 路径不能包含斜杠字符以确保安全路由

func (*PageSite) SetPage

func (s *PageSite) SetPage(path string, page []byte) string

SetPage registers HTML page content at specified path and returns access URL Stores page content in process and generates accessible URL Path must not contain slash characters to ensure safe routing

SetPage 在指定路径注册 HTML 页面内容并返回访问 URL 将页面内容存储在进程中并生成可访问的 URL 路径不能包含斜杠字符以确保安全路由

Jump to

Keyboard shortcuts

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