request

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2025 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

* @Author: jffan * @Date: 2024-07-29 14:56:25 * @LastEditTime: 2024-07-29 15:23:49 * @LastEditors: jffan * @FilePath: \tcas-cli\utils\request\request.go * @Description: Copyright © 2024 <jffan@nanhulab.ac.cn>

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Request

type Request struct {
	Method  string
	URL     string
	Headers map[string]string
	Query   map[string]string
	Body    interface{}
}

Request is a struct to hold request parameters

func Delete

func Delete(url string) *Request

Delete is a shortcut for creating a DELETE request

func Get

func Get(url string) *Request

Get is a shortcut for creating a GET request

func NewRequest

func NewRequest(method, url string) *Request

NewRequest creates a new Request instance

func Post

func Post(url string) *Request

Post is a shortcut for creating a POST request

func Put

func Put(url string) *Request

Put is a shortcut for creating a PUT request

func (*Request) Do

func (r *Request) Do() (*http.Response, error)

Do sends the request and returns the response

func (*Request) DoWithBody

func (r *Request) DoWithBody(v interface{}) (*http.Response, error)

DoWithBody sends the request and returns the response with body as an interface{}

func (*Request) SetBody

func (r *Request) SetBody(body interface{}) *Request

SetBody sets the body for the request

func (*Request) SetHeader

func (r *Request) SetHeader(key, value string) *Request

SetHeader sets a header for the request

func (*Request) SetQuery

func (r *Request) SetQuery(key, value string) *Request

SetQuery sets a query parameter for the request

Jump to

Keyboard shortcuts

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