跳至主要内容

URL 缩短器 API

Github StackBlitz

本项目提供一个带简单 API 的 URL 缩短服务。

技术栈

  • Golang
  • Redis

API 文档

API 端点:http://localhost:3000/api/v1/

API 请求体

  • url - 原始 URL
  • short - 自定义短 URL (可选)
  • expiry - 过期时间:整型 (小时)

API 响应

  • url - 原始 URL
  • short - 自定义短 URL
  • expiry - 过期时间:整型 (小时)
  • rate_limit - 剩余 API 调用次数:整型
  • rate_limit_reset - 速率限制重置时间:整型 (分钟)

API 速率限制为每 30 分钟 10 次调用。这些值可以在 .env 文件中更改。玩得开心。

设置

  1. 启动容器

    docker-compose up -d
  2. 测试 API: test.gif