Init: bootstrap go module with basic framework

This commit is contained in:
2025-09-25 08:14:34 +08:00
commit 60f534be1e
47 changed files with 1084 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
package api
import (
"net/http"
"github.com/uptrace/bunrouter"
)
func (*Handlers) GetAliases(
w http.ResponseWriter,
req bunrouter.Request,
) error {
return nil
}

28
handlers/api/getImage.go Normal file
View File

@@ -0,0 +1,28 @@
package api
import (
"net/http"
"gitea.konchin.com/service/amane-tanikaze-dcbot/amane/middlewares"
"gitea.konchin.com/service/amane-tanikaze-dcbot/amane/utils"
"github.com/uptrace/bunrouter"
)
// GetImage
//
// @Param id query string true "image id"
// @Success 200
// @Router /api/image [get]
func (*Handlers) GetImage(
w http.ResponseWriter,
req bunrouter.Request,
) error {
imageId := req.URL.Query().Get("id")
if imageId == "" {
return middlewares.HTTPError{
StatusCode: http.StatusBadRequest,
Message: "must provide id",
}
}
return utils.Success(w)
}

11
handlers/api/handlers.go Normal file
View File

@@ -0,0 +1,11 @@
package api
import "github.com/uptrace/bun"
type Handlers struct {
db *bun.DB
}
func NewHandlers(db *bun.DB) *Handlers {
return &Handlers{db: db}
}

View File

@@ -0,0 +1 @@
package api

1
handlers/api/putImage.go Normal file
View File

@@ -0,0 +1 @@
package api