momo

package module
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2024 License: GPL-3.0 Imports: 1 Imported by: 0

README

momo

介绍

go语言写的实用类库

软件架构

软件架构说明

安装教程
  1. xxxx
  2. xxxx
  3. xxxx
使用说明
  1. httptool: // DEMO // type APIResponse struct { // Success bool json:"success" // Code int json:"code" // Data interface{} json:"data,omitempty" // }

// func testGet(c *gin.Context) { // // GET请求示例 // url := c.Query("url") // httpBuilder, err := httptools.NewRequestBuilder[APIResponse](http.MethodGet, url) // if err != nil { // httptools.HandleApiError(c, 500, "getBuilder error", fmt.Sprintf("%+v", err)) // return // } // statusCode, res, err := httpBuilder.Send() // if err != nil { // httptools.HandleApiError(c, statusCode, "httpsend error", fmt.Sprintf("%+v", err)) // return // }

// c.JSON(statusCode, res) // }

// func testPost(c *gin.Context) { // url := c.Query("url") // // 使用构建器模式创建请求 // httpBuilder, err := httptools.NewRequestBuilder[APIResponse](http.MethodPost, url) // if err != nil { // httptools.HandleApiError(c, 500, "httpbuilder error", fmt.Sprintf("%+v", err)) // return // } // httpBuilder.WithJSONBody(map[string]interface{}{"key": "value"}) // httpBuilder.WithHeader("X-Custom-Header", "CustomValue") // httpBuilder.WithBaseAuth("admin", "admin")

// statusCode, res, err := httpBuilder.Send() // if err != nil { // httptools.HandleApiError(c, statusCode, "httpsend error", fmt.Sprintf("%+v", err)) // return // } // c.JSON(statusCode, res) // }

// func testDownload(c *gin.Context) { // url := c.Query("url") // // 使用构建器模式创建请求 // httpBuilder, err := httptools.NewRequestBuilder[APIResponse](http.MethodGet, url) // if err != nil { // httptools.HandleApiError(c, 500, "httpbuilder error", fmt.Sprintf("%+v", err)) // return // } // httpBuilder.WithHeader("X-Custom-Header", "CustomValue").WithBaseAuth("admin", "admin").SetTimeout(30) // buffer, statusCode, err := httpBuilder.DownloadFile() // if err != nil { // httptools.HandleApiError(c, statusCode, "httpsend error", fmt.Sprintf("%+v", err)) // return // } // err = httpBuilder.SaveToDisk(buffer, "test.jpg") // if err != nil { // httptools.HandleApiError(c, statusCode, "saveToDisk error", fmt.Sprintf("%+v", err)) // return // } // c.JSON(statusCode, httpBuilder.Resp) // }

// func PostAndUnmarshal(path string, body string, v any) error { // req := url.NewRequest() // req.Body = body // r, err := requests.Post(path, req) // if err != nil { // fmt.Println(err) // return err // } // return json.Unmarshal(r.Content, v) // }

参与贡献
  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request
特技
  1. 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
  2. Gitee 官方博客 blog.gitee.com
  3. 你可以 https://gitee.com/explore 这个地址来了解 Gitee 上的优秀开源项目
  4. GVP 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
  5. Gitee 官方提供的使用手册 https://gitee.com/help
  6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 https://gitee.com/gitee-stars/

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HelloWorld

func HelloWorld(name string)

func Run added in v1.3.0

func Run(param string) error

Types

This section is empty.

Directories

Path Synopsis
app
controllers/base_controller.go
controllers/base_controller.go
dsl
service/base_service.go
service/base_service.go

Jump to

Keyboard shortcuts

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