gtools

module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: Apache-2.0

README

一个golang 的学习工具包

curl -X POST -H "Content-Type: application/json" -d '{"username":"xxx", "password":"u1"}' 'http://localhost:8080/admin/user?id=2&name=u2'
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d 'username=xxx&&password=12345678' 'http://localhost:8080/admin/user?id=2&name=u2'
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d 'username=admin&&password=password' 'http://localhost:8080/public/login'
curl  'http://localhost:8080/admin'
curl -H "token: bear eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsZXNzZWVfaWQiOiJsZWVzc2VlaWQiLCJ1c2VyX2lkIjoidXNlcmlkIiwidXNlcm5hbWUiOiJ1c2VybmFtZSIsImF1ZCI6Imd0b29scy5hZG1pbiIsImV4cCI6MTUwMDAsImp0aSI6Imd0b29scyIsImlhdCI6MTczMDg4MDg3Mzk5MywiaXNzIjoiZ3Rvb2xzIiwibmJmIjoxNzMwODgwODczOTkzLCJzdWIiOiJndG9vbHMifQ.cC6NVpLU42g46XD7wcbpZhrJsTsNlNk5tPMm2lT-UtU" 'http://localhost:8080/admin'
curl -H "token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsZXNzZWVfaWQiOiJsZWVzc2VlaWQiLCJ1c2VyX2lkIjoidXNlcmlkIiwidXNlcm5hbWUiOiJ1c2VybmFtZSIsImF1ZCI6Imd0b29scy5hZG1pbiIsImV4cCI6MTczMTc0NTk0MiwianRpIjoiZ3Rvb2xzIiwiaWF0IjoxNzMwODgxOTQyLCJpc3MiOiJndG9vbHMiLCJuYmYiOjE3MzA4ODE5NDIsInN1YiI6Imd0b29scyJ9.0Vl-2VlujnVfmOCWUSOyqwa4syxjTTetzkWoSbT0pXw" 'http://localhost:8080/admin'
curl -X POST -H "token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsZXNzZWVfaWQiOiJsZWVzc2VlaWQiLCJ1c2VyX2lkIjoidXNlcmlkIiwidXNlcm5hbWUiOiJ1c2VybmFtZSIsImF1ZCI6Imd0b29scy5hZG1pbiIsImV4cCI6MTczMTc0NTk0MiwianRpIjoiZ3Rvb2xzIiwiaWF0IjoxNzMwODgxOTQyLCJpc3MiOiJndG9vbHMiLCJuYmYiOjE3MzA4ODE5NDIsInN1YiI6Imd0b29scyJ9.0Vl-2VlujnVfmOCWUSOyqwa4syxjTTetzkWoSbT0pXw" 'http://localhost:8080/admin/user'

curl -H "token: bear eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsZXNzZWVfaWQiOiJsZWVzc2VlaWQiLCJ1c2VyX2lkIjoidXNlcmlkIiwidXNlcm5hbWUiOiJ1c2VybmFtZSIsImF1ZCI6Imd0b29scy5hZG1pbiIsImV4cCI6MTczMzk4NTY5OCwianRpIjoiZ3Rvb2xzIiwiaWF0IjoxNzMzMTIxNjk4LCJpc3MiOiJndG9vbHMiLCJuYmYiOjE3MzMxMjE2OTgsInN1YiI6Imd0b29scyJ9.bNrfqhaP4v6GPhAMVVARL3Au0LVhbuIa0Ea1vuIVTKU" 'http://localhost:8080/admin/user/2'



curl -X POST -H "token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsZXNzZWVfaWQiOiJsZWVzc2VlaWQiLCJ1c2VyX2lkIjoidXNlcmlkIiwidXNlcm5hbWUiOiJ1c2VybmFtZSIsImF1ZCI6Imd0b29scy5hZG1pbiIsImV4cCI6MTczNDYwMjE5NywianRpIjoiMzU4TFpZY3YiLCJpYXQiOjE3MzM3MzgxOTcsImlzcyI6Imd0b29scyIsIm5iZiI6MTczMzczODE5Nywic3ViIjoiZ3Rvb2xzIn0.GBOblTJ4uDo6nzc2RtDaQc-S-bnzmy4_YHeVT1xG9oc" http://localhost:8080/admin/message -d 'title=time&content=hello&type=1'
优雅退出
kill -SIGINT $(cat .pid)

学习路线

casbin
jwt
# 保存 http 的header 信息
curl -D header.txt http://localhost:8080/public/login -d 'username=admin&password=password'

优雅退出
  • 进程启动,启动一个协程监听端口并提供服务。
  • 创建一个退出信号的channel, 这个channel 的长度不能是0,防止未处理而丢弃。监听退出信号,通常监听的信号有 os.Interrupt 和 syscall.SIGTERM。
  • 监听到信号以后,stop service,做优雅退出操作。
zaplog
接口限流
openresty
rpc
服务注册与发现
websocket
SSE
分段下载
图片验证码

图片验证码的库 captcha 说明,改库提供了图片验证码的生成和验证功能。

  1. 生成验证码:需要定义生成的图片验证码的 宽、高、字符范围,噪音、验证码长度等,这样就可以按照指定的规格生成验证码;生成验证码可以返回验证码的ID和图片内容信息;
  2. 验证验证码:需要提供验证码的值,验证码的ID;这样就可以在验证码的存储引擎里做比对;默认的存储引擎是基于内存的,仅支持单机场景;如果要分布式场景,则需要提供redis实例; 测试脚本
curl http://localhost:8080/public/vcode --output vcode.png -c cookie
curl -X POST -b cookie http://localhost:8080/public/vcode -d 'code=3590'
文档操作,excel\doc\pdf\image
excel
doc
pdf
image
markdown

Directories

Path Synopsis
examples
zaplog/service
Package service is a generated GoMock package.
Package service is a generated GoMock package.
internal
pkg
jwt
service
pb

Jump to

Keyboard shortcuts

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