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

View File

@@ -0,0 +1 @@
package auth

59
handlers/docs/docs.go Normal file
View File

@@ -0,0 +1,59 @@
// Package docs Code generated by swaggo/swag. DO NOT EDIT
package docs
import "github.com/swaggo/swag"
const docTemplate = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
"description": "{{escape .Description}}",
"title": "{{.Title}}",
"termsOfService": "http://swagger.io/terms/",
"contact": {},
"license": {
"name": "0BSD"
},
"version": "{{.Version}}"
},
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/api/image": {
"get": {
"parameters": [
{
"type": "string",
"description": "image id",
"name": "id",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "OK"
}
}
}
}
}
}`
// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = &swag.Spec{
Version: "2.0-alpha1",
Host: "",
BasePath: "/",
Schemes: []string{},
Title: "Amane Tanikaze Discord Bot Backend",
Description: "",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
LeftDelim: "{{",
RightDelim: "}}",
}
func init() {
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
}

View File

@@ -0,0 +1,33 @@
{
"swagger": "2.0",
"info": {
"title": "Amane Tanikaze Discord Bot Backend",
"termsOfService": "http://swagger.io/terms/",
"contact": {},
"license": {
"name": "0BSD"
},
"version": "2.0-alpha1"
},
"basePath": "/",
"paths": {
"/api/image": {
"get": {
"parameters": [
{
"type": "string",
"description": "image id",
"name": "id",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "OK"
}
}
}
}
}
}

View File

@@ -0,0 +1,21 @@
basePath: /
info:
contact: {}
license:
name: 0BSD
termsOfService: http://swagger.io/terms/
title: Amane Tanikaze Discord Bot Backend
version: 2.0-alpha1
paths:
/api/image:
get:
parameters:
- description: image id
in: query
name: id
required: true
type: string
responses:
"200":
description: OK
swagger: "2.0"