zipclient

package
v1.49.14 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiError

type ApiError struct {
	Error struct {
		Type    string `json:"type"`
		Message string `json:"message"`
	} `json:"error"`
}

type Client

type Client struct {
	Router zip.Router
	// contains filtered or unexported fields
}

Client drives a zip.App under test the way the old ginclient drove a gin.Engine: register routes/middleware on Router, then issue requests that return an *httptest.ResponseRecorder (Code/Body) exactly as before. Requests run through the zap-proto/fiber net/http adaptor, so the full middleware chain and routing are exercised — no gin, no shims.

There is deliberately no post-request Context handle (the old ginclient exposed one): fiber pools and resets the *Ctx when the request completes, so reading it afterward panics. A test that needs the resolved context state reads it INSIDE the handler it registers (where the Ctx is live).

func New

func New(ctx ae.Context) *Client

func (*Client) App

func (cl *Client) App() *zip.App

App exposes the backing zip app (route dumps, direct Fiber().Test drives).

func (*Client) Defaults

func (cl *Client) Defaults(fn defaultsFunc)

Set defaults for each request

func (*Client) Delete

func (cl *Client) Delete(uri string, args ...interface{}) *httptest.ResponseRecorder

Make DELETE request Accepts optional args: int (expected status code, default 204), url.Values (query params), or any other type (decoded as JSON response destination).

func (*Client) Do

func (*Client) Get

func (cl *Client) Get(uri string, res interface{}, args ...interface{}) *httptest.ResponseRecorder

Make GET request

func (*Client) Handle

func (cl *Client) Handle(method, path string, handler zip.Handler)

Add a new handler to router

func (*Client) Head

func (cl *Client) Head(uri string, args ...interface{}) *httptest.ResponseRecorder

Make HEAD request

func (*Client) IgnoreErrors

func (cl *Client) IgnoreErrors(ignore bool)

func (*Client) NewRequest

func (cl *Client) NewRequest(method, uri string, reader io.Reader) *http.Request

func (*Client) Options

func (cl *Client) Options(uri string, args ...interface{}) *httptest.ResponseRecorder

Make OPTIONS request

func (*Client) Patch

func (cl *Client) Patch(uri string, body interface{}, res interface{}, args ...interface{}) *httptest.ResponseRecorder

Make PATCH request

func (*Client) Post

func (cl *Client) Post(uri string, body interface{}, res interface{}, args ...interface{}) *httptest.ResponseRecorder

Make POST request

func (*Client) PostForm

func (c *Client) PostForm(path string, data url.Values) *httptest.ResponseRecorder

Make POST with Form Data

func (*Client) PostJSON

func (c *Client) PostJSON(path string, src interface{}) *httptest.ResponseRecorder

Make POST with JSON Data

func (*Client) PostRawJSON

func (c *Client) PostRawJSON(path string, src string) *httptest.ResponseRecorder

Make POST with Raw JSON Data

func (*Client) Put

func (cl *Client) Put(uri string, body interface{}, res interface{}, args ...interface{}) *httptest.ResponseRecorder

Make PUT request

func (*Client) Use

func (cl *Client) Use(mw ...zip.Handler)

Add middleware to router

Jump to

Keyboard shortcuts

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