http

package
v0.0.0-...-fa5f906 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package http 提供 net/http 包的一些工具

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JSON

func JSON[T any](ctx context.Context, targetURL string, opts ...RequestOption) (rsp T, err error)

JSON 发起一个 JSON 请求

func NormalizeHeader

func NormalizeHeader(h http.Header) http.Header

NormalizeHeader 返回统一 mine key 格式的 header

Types

type RequestOption

type RequestOption func(*requestOption)

发起请求的额外选项

func WithMethod

func WithMethod(method string) RequestOption

WithMethod 指定 HTTP 调用方法

func WithQuery

func WithQuery(q url.Values) RequestOption

WithQuery query 参数

func WithRequestBody

func WithRequestBody(req any) RequestOption

WithRequestBody 请求正文

func WithRequestHeader

func WithRequestHeader(h http.Header) RequestOption

WithRequestHeader 指定请求头参数

Jump to

Keyboard shortcuts

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