This commit is contained in:
2025-10-24 21:44:15 +08:00
parent 2f56813874
commit 289812aac3
18 changed files with 576 additions and 100 deletions

View File

@@ -1,39 +1,64 @@
syntax = "v1"
info (
title: "Blog API"
desc: "API for blog application with file operations"
author: "user"
date: "2025-10-24"
version: "v1"
title: "Blog API"
desc: "API for blog application"
author: "cialloo"
date: "2025-10-24"
version: "v1"
)
type UploadReq {
FileName string `json:"fileName"`
}
type (
PingReq {}
PingResp {
ok bool `json:"ok"`
}
)
type UploadResp {
PresignedUrl string `json:"presignedUrl"`
}
type (
UploadPresignedURLReq {
file_name string `json:"file_name"` // Original file name
}
UploadPresignedURLResp {
url string `json:"url"` // Presigned URL for upload
file_key string `json:"file_key"` // Key to identify the uploaded file
expire_at int64 `json:"expire_at"` // Expiration timestamp
}
)
type DownloadReq {
FileKey string `json:"fileKey"`
}
type DownloadResp {
PresignedUrl string `json:"presignedUrl"`
}
type (
DownloadPresignedURLReq {
file_key string `json:"file_key"` // Key to identify the file to download
}
DownloadPresignedURLResp {
url string `json:"url"` // Presigned URL for download
expire_at int64 `json:"expire_at"` // Expiration timestamp
}
)
@server (
prefix: /api/v1
prefix: /api/blog
)
service Blog {
@handler uploadFile
post /files/upload (UploadReq) returns (UploadResp)
@doc (
summary: "Ping the server to check if it's alive"
description: "Ping the server to check if it's alive"
)
@handler pingHandler
get /ping (PingReq) returns (PingResp)
@handler downloadFile
get /files/download (DownloadReq) returns (DownloadResp)
@doc (
summary: "Get presigned URL for file upload"
description: "Get presigned URL for file upload"
)
@handler UploadPresignedURLHandler
post /file/upload (UploadPresignedURLReq) returns (UploadPresignedURLResp)
@handler previewFile
get /files/preview (DownloadReq) returns (DownloadResp)
@doc (
summary: "Get presigned URL for file download"
description: "Get presigned URL for file download"
)
@handler DownloadPresignedURLHandler
post /file/download (DownloadPresignedURLReq) returns (DownloadPresignedURLResp)
}