diff --git a/api/ping.go b/api/ping.go index 1572391..bbdea29 100644 --- a/api/ping.go +++ b/api/ping.go @@ -6,6 +6,14 @@ import ( "github.com/labstack/echo/v4" ) +// Ping godoc +// @Summary Ping the server +// @Description Get a pong response +// @Tags ping +// @Accept json +// @Produce json +// @Success 200 {string} string "Pong!" +// @Router /ping [get] func Ping(c echo.Context) error { return c.String(http.StatusOK, "Pong!") } diff --git a/api/post.copy.go b/api/post.copy.go index 6e80cd9..a41ca39 100644 --- a/api/post.copy.go +++ b/api/post.copy.go @@ -6,6 +6,14 @@ import ( "github.com/labstack/echo/v4" ) +// PostCopy godoc +// @Summary Get copy icon SVG +// @Description Returns an SVG of a copy icon +// @Tags post +// @Accept json +// @Produce html +// @Success 200 {string} string "SVG content" +// @Router /post/copy [get] func PostCopy(c echo.Context) error { return c.String(http.StatusOK, ``) } diff --git a/api/rss.go b/api/rss.go index f43036a..22f5f80 100644 --- a/api/rss.go +++ b/api/rss.go @@ -1,5 +1,14 @@ package api +// RSSFeedHandler godoc +// @Summary Get RSS feed +// @Description Returns an RSS feed of blog posts +// @Tags rss +// @Accept json +// @Produce xml +// @Success 200 {string} string "RSS feed content" +// @Failure 500 {string} string "Internal Server Error" +// @Router /rss [get] import ( "io/fs" "net/http" diff --git a/api/sse.go b/api/sse.go index e2bed48..96372cd 100644 --- a/api/sse.go +++ b/api/sse.go @@ -8,6 +8,15 @@ import ( "github.com/labstack/echo/v4" ) +// SSE godoc +// @Summary Server-Sent Events endpoint +// @Description Establishes a Server-Sent Events connection +// @Tags sse +// @Accept json +// @Produce text/event-stream +// @Param channel query string false "Channel name" +// @Success 200 {string} string "Event stream" +// @Router /sse [get] func SSE(c echo.Context) error { channel := c.QueryParam("channel") if channel == "" { diff --git a/api/tools.resize.go b/api/tools.resize.go index b4dd938..f193e9f 100644 --- a/api/tools.resize.go +++ b/api/tools.resize.go @@ -9,6 +9,19 @@ import ( "github.com/labstack/echo/v4" ) +// ResizeHandler godoc +// @Summary Resize an image +// @Description Resizes an uploaded image to specified dimensions +// @Tags tools +// @Accept mpfd +// @Produce png +// @Param image formData file true "Image file to resize" +// @Param width formData int true "Target width" +// @Param height formData int true "Target height" +// @Success 200 {file} binary "Resized image" +// @Failure 400 {string} string "Bad request" +// @Failure 500 {string} string "Internal server error" +// @Router /tools/resize [post] func ResizeHandler(c echo.Context) error { // Extract file from request diff --git a/api/tools.sendsse.go b/api/tools.sendsse.go index 5337442..5d32dd5 100644 --- a/api/tools.sendsse.go +++ b/api/tools.sendsse.go @@ -7,6 +7,17 @@ import ( "github.com/labstack/echo/v4" ) +// SSEDemoSend godoc +// @Summary Send SSE message +// @Description Sends a message to a specified SSE channel +// @Tags sse,tools +// @Accept json +// @Produce json +// @Param channel query string false "Channel name" +// @Param message query string false "Message to send" +// @Success 200 {object} map[string]string +// @Failure 400 {object} map[string]string +// @Router /tools/sendsse [post] func SSEDemoSend(c echo.Context) error { channel := c.QueryParam("channel") if channel == "" { diff --git a/docs/docs.go b/docs/docs.go new file mode 100644 index 0000000..42d6560 --- /dev/null +++ b/docs/docs.go @@ -0,0 +1,222 @@ +// 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}}", + "contact": {}, + "version": "{{.Version}}" + }, + "host": "{{.Host}}", + "basePath": "{{.BasePath}}", + "paths": { + "/ping": { + "get": { + "description": "Get a pong response", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "ping" + ], + "summary": "Ping the server", + "responses": { + "200": { + "description": "Pong!", + "schema": { + "type": "string" + } + } + } + } + }, + "/post/copy": { + "get": { + "description": "Returns an SVG of a copy icon", + "consumes": [ + "application/json" + ], + "produces": [ + "text/html" + ], + "tags": [ + "post" + ], + "summary": "Get copy icon SVG", + "responses": { + "200": { + "description": "SVG content", + "schema": { + "type": "string" + } + } + } + } + }, + "/sse": { + "get": { + "description": "Establishes a Server-Sent Events connection", + "consumes": [ + "application/json" + ], + "produces": [ + "text/event-stream" + ], + "tags": [ + "sse" + ], + "summary": "Server-Sent Events endpoint", + "parameters": [ + { + "type": "string", + "description": "Channel name", + "name": "channel", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Event stream", + "schema": { + "type": "string" + } + } + } + } + }, + "/tools/resize": { + "post": { + "description": "Resizes an uploaded image to specified dimensions", + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "image/png" + ], + "tags": [ + "tools" + ], + "summary": "Resize an image", + "parameters": [ + { + "type": "file", + "description": "Image file to resize", + "name": "image", + "in": "formData", + "required": true + }, + { + "type": "integer", + "description": "Target width", + "name": "width", + "in": "formData", + "required": true + }, + { + "type": "integer", + "description": "Target height", + "name": "height", + "in": "formData", + "required": true + } + ], + "responses": { + "200": { + "description": "Resized image", + "schema": { + "type": "file" + } + }, + "400": { + "description": "Bad request", + "schema": { + "type": "string" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "type": "string" + } + } + } + } + }, + "/tools/sendsse": { + "post": { + "description": "Sends a message to a specified SSE channel", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "sse", + "tools" + ], + "summary": "Send SSE message", + "parameters": [ + { + "type": "string", + "description": "Channel name", + "name": "channel", + "in": "query" + }, + { + "type": "string", + "description": "Message to send", + "name": "message", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + } + } +}` + +// SwaggerInfo holds exported Swagger Info so clients can modify it +var SwaggerInfo = &swag.Spec{ + Version: "1.0", + Host: "localhost:3000", + BasePath: "/api", + Schemes: []string{}, + Title: "Atri.dad API", + Description: "This is the API for atri.dad", + InfoInstanceName: "swagger", + SwaggerTemplate: docTemplate, + LeftDelim: "{{", + RightDelim: "}}", +} + +func init() { + swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) +} diff --git a/docs/swagger.json b/docs/swagger.json new file mode 100644 index 0000000..54c014b --- /dev/null +++ b/docs/swagger.json @@ -0,0 +1,198 @@ +{ + "swagger": "2.0", + "info": { + "description": "This is the API for atri.dad", + "title": "Atri.dad API", + "contact": {}, + "version": "1.0" + }, + "host": "localhost:3000", + "basePath": "/api", + "paths": { + "/ping": { + "get": { + "description": "Get a pong response", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "ping" + ], + "summary": "Ping the server", + "responses": { + "200": { + "description": "Pong!", + "schema": { + "type": "string" + } + } + } + } + }, + "/post/copy": { + "get": { + "description": "Returns an SVG of a copy icon", + "consumes": [ + "application/json" + ], + "produces": [ + "text/html" + ], + "tags": [ + "post" + ], + "summary": "Get copy icon SVG", + "responses": { + "200": { + "description": "SVG content", + "schema": { + "type": "string" + } + } + } + } + }, + "/sse": { + "get": { + "description": "Establishes a Server-Sent Events connection", + "consumes": [ + "application/json" + ], + "produces": [ + "text/event-stream" + ], + "tags": [ + "sse" + ], + "summary": "Server-Sent Events endpoint", + "parameters": [ + { + "type": "string", + "description": "Channel name", + "name": "channel", + "in": "query" + } + ], + "responses": { + "200": { + "description": "Event stream", + "schema": { + "type": "string" + } + } + } + } + }, + "/tools/resize": { + "post": { + "description": "Resizes an uploaded image to specified dimensions", + "consumes": [ + "multipart/form-data" + ], + "produces": [ + "image/png" + ], + "tags": [ + "tools" + ], + "summary": "Resize an image", + "parameters": [ + { + "type": "file", + "description": "Image file to resize", + "name": "image", + "in": "formData", + "required": true + }, + { + "type": "integer", + "description": "Target width", + "name": "width", + "in": "formData", + "required": true + }, + { + "type": "integer", + "description": "Target height", + "name": "height", + "in": "formData", + "required": true + } + ], + "responses": { + "200": { + "description": "Resized image", + "schema": { + "type": "file" + } + }, + "400": { + "description": "Bad request", + "schema": { + "type": "string" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "type": "string" + } + } + } + } + }, + "/tools/sendsse": { + "post": { + "description": "Sends a message to a specified SSE channel", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "sse", + "tools" + ], + "summary": "Send SSE message", + "parameters": [ + { + "type": "string", + "description": "Channel name", + "name": "channel", + "in": "query" + }, + { + "type": "string", + "description": "Message to send", + "name": "message", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/docs/swagger.yaml b/docs/swagger.yaml new file mode 100644 index 0000000..12d3e8f --- /dev/null +++ b/docs/swagger.yaml @@ -0,0 +1,131 @@ +basePath: /api +host: localhost:3000 +info: + contact: {} + description: This is the API for atri.dad + title: Atri.dad API + version: "1.0" +paths: + /ping: + get: + consumes: + - application/json + description: Get a pong response + produces: + - application/json + responses: + "200": + description: Pong! + schema: + type: string + summary: Ping the server + tags: + - ping + /post/copy: + get: + consumes: + - application/json + description: Returns an SVG of a copy icon + produces: + - text/html + responses: + "200": + description: SVG content + schema: + type: string + summary: Get copy icon SVG + tags: + - post + /sse: + get: + consumes: + - application/json + description: Establishes a Server-Sent Events connection + parameters: + - description: Channel name + in: query + name: channel + type: string + produces: + - text/event-stream + responses: + "200": + description: Event stream + schema: + type: string + summary: Server-Sent Events endpoint + tags: + - sse + /tools/resize: + post: + consumes: + - multipart/form-data + description: Resizes an uploaded image to specified dimensions + parameters: + - description: Image file to resize + in: formData + name: image + required: true + type: file + - description: Target width + in: formData + name: width + required: true + type: integer + - description: Target height + in: formData + name: height + required: true + type: integer + produces: + - image/png + responses: + "200": + description: Resized image + schema: + type: file + "400": + description: Bad request + schema: + type: string + "500": + description: Internal server error + schema: + type: string + summary: Resize an image + tags: + - tools + /tools/sendsse: + post: + consumes: + - application/json + description: Sends a message to a specified SSE channel + parameters: + - description: Channel name + in: query + name: channel + type: string + - description: Message to send + in: query + name: message + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + additionalProperties: + type: string + type: object + "400": + description: Bad Request + schema: + additionalProperties: + type: string + type: object + summary: Send SSE message + tags: + - sse + - tools +swagger: "2.0" diff --git a/go.mod b/go.mod index dd0e3ff..27c260a 100644 --- a/go.mod +++ b/go.mod @@ -5,17 +5,32 @@ go 1.23.1 require github.com/alecthomas/chroma/v2 v2.14.0 require ( + github.com/KyleBanks/depth v1.2.1 // indirect + github.com/PuerkitoBio/purell v1.2.1 // indirect + github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect github.com/dlclark/regexp2 v1.11.4 // indirect + github.com/ghodss/yaml v1.0.0 // indirect + github.com/go-openapi/jsonpointer v0.21.0 // indirect + github.com/go-openapi/jsonreference v0.21.0 // indirect + github.com/go-openapi/spec v0.21.0 // indirect + github.com/go-openapi/swag v0.23.0 // indirect github.com/golang-jwt/jwt v3.2.2+incompatible // indirect + github.com/josharian/intern v1.0.0 // indirect github.com/labstack/gommon v0.4.2 // indirect + github.com/mailru/easyjson v0.7.7 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect + github.com/swaggo/echo-swagger v1.4.1 // indirect + github.com/swaggo/files/v2 v2.0.1 // indirect + github.com/swaggo/swag v1.16.4 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasttemplate v1.2.2 // indirect golang.org/x/image v0.21.0 // indirect golang.org/x/net v0.30.0 // indirect golang.org/x/text v0.19.0 // indirect golang.org/x/time v0.7.0 // indirect - gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect + golang.org/x/tools v0.26.0 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) require ( diff --git a/go.sum b/go.sum index 4425958..05d2178 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,9 @@ +github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= +github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= +github.com/PuerkitoBio/purell v1.2.1 h1:QsZ4TjvwiMpat6gBCBxEQI0rcS9ehtkKtSpiUnd9N28= +github.com/PuerkitoBio/purell v1.2.1/go.mod h1:ZwHcC/82TOaovDi//J/804umJFFmbOHPngi8iYYv/Eo= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/alecthomas/assert/v2 v2.7.0 h1:QtqSACNS3tF7oasA8CU6A6sXZSBDqnm7RfpLl9bZqbE= github.com/alecthomas/assert/v2 v2.7.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= github.com/alecthomas/chroma/v2 v2.2.0/go.mod h1:vf4zrexSH54oEjJ7EdB65tGNHmH3pGZmVkgTP5RHvAs= @@ -17,6 +23,16 @@ github.com/dlclark/regexp2 v1.11.4 h1:rPYF9/LECdNymJufQKmri9gV604RvvABwgOA8un7yA github.com/dlclark/regexp2 v1.11.4/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ= +github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY= +github.com/go-openapi/jsonreference v0.21.0 h1:Rs+Y7hSXT83Jacb7kFyjn4ijOuVGSvOdF2+tg1TRrwQ= +github.com/go-openapi/jsonreference v0.21.0/go.mod h1:LmZmgsrTkVg9LG4EaHeY8cBDslNPMo06cago5JNLkm4= +github.com/go-openapi/spec v0.21.0 h1:LTVzPc3p/RzRnkQqLRndbAzjY0d0BCL72A6j3CdL9ZY= +github.com/go-openapi/spec v0.21.0/go.mod h1:78u6VdPw81XU44qEWGhtr982gJ5BWg2c0I5XwVMotYk= +github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE= +github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ= github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/gorilla/feeds v1.2.0 h1:O6pBiXJ5JHhPvqy53NsjKOThq+dNFm8+DFrxBEdzSCc= @@ -25,14 +41,21 @@ github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUq github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= +github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/labstack/echo/v4 v4.12.0 h1:IKpw49IMryVB2p1a4dzwlhP1O2Tf2E0Ir/450lH+kI0= github.com/labstack/echo/v4 v4.12.0/go.mod h1:UP9Cr2DJXbOK3Kr9ONYzNowSh7HP0aG0ShAyycHSJvM= github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0= github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU= +github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= @@ -46,6 +69,12 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/swaggo/echo-swagger v1.4.1 h1:Yf0uPaJWp1uRtDloZALyLnvdBeoEL5Kc7DtnjzO/TUk= +github.com/swaggo/echo-swagger v1.4.1/go.mod h1:C8bSi+9yH2FLZsnhqMZLIZddpUxZdBYuNHbtaS1Hljc= +github.com/swaggo/files/v2 v2.0.1 h1:XCVJO/i/VosCDsJu1YLpdejGsGnBE9deRMpjN4pJLHk= +github.com/swaggo/files/v2 v2.0.1/go.mod h1:24kk2Y9NYEJ5lHuCra6iVwkMjIekMCaFq/0JQj66kyM= +github.com/swaggo/swag v1.16.4 h1:clWJtd9LStiG3VeijiCfOVODP6VpHtKdQy9ELFG3s1A= +github.com/swaggo/swag v1.16.4/go.mod h1:VBsHJRsDvfYvqoiMKnsdwhNV9LEMHgEDZcyVYX0sxPg= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo= @@ -71,9 +100,13 @@ golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ= golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= +golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ= +golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/main.go b/main.go index ac51685..7b4734b 100755 --- a/main.go +++ b/main.go @@ -10,14 +10,21 @@ import ( "atri.dad/lib" "atri.dad/pages" + _ "atri.dad/docs" "github.com/joho/godotenv" "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" + echoSwagger "github.com/swaggo/echo-swagger" ) //go:embed public/* var PublicFS embed.FS +// @title Atri.dad API +// @version 1.0 +// @description This is the API for atri.dad +// @host localhost:3000 +// @BasePath /api func main() { // Load environment variables godotenv.Load(".env") @@ -52,6 +59,8 @@ func main() { // API Routes: apiGroup := e.Group("/api") + // Swagger endpoint + apiGroup.GET("/swagger/*", echoSwagger.WrapHandler) apiGroup.GET("/ping", api.Ping) apiGroup.GET("/rss", api.RSSFeedHandler) apiGroup.GET("/post/copy", api.PostCopy)