Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed lint errors after refactor #806

Merged
merged 3 commits into from Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/swagger/docs.go
Expand Up @@ -150,7 +150,7 @@ const docTemplate = `{
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/model.Bookmark"
"$ref": "#/definitions/model.BookmarkDTO"
}
},
"403": {
Expand Down Expand Up @@ -294,16 +294,18 @@ const docTemplate = `{
}
}
},
"model.Bookmark": {
"model.BookmarkDTO": {
"type": "object",
"properties": {
"author": {
"type": "string"
},
"create_archive": {
"description": "TODO: migrate outside the DTO",
"type": "boolean"
},
"create_ebook": {
"description": "TODO: migrate outside the DTO",
"type": "boolean"
},
"excerpt": {
Expand Down
6 changes: 4 additions & 2 deletions docs/swagger/swagger.json
Expand Up @@ -139,7 +139,7 @@
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/model.Bookmark"
"$ref": "#/definitions/model.BookmarkDTO"
}
},
"403": {
Expand Down Expand Up @@ -283,16 +283,18 @@
}
}
},
"model.Bookmark": {
"model.BookmarkDTO": {
"type": "object",
"properties": {
"author": {
"type": "string"
},
"create_archive": {
"description": "TODO: migrate outside the DTO",
"type": "boolean"
},
"create_ebook": {
"description": "TODO: migrate outside the DTO",
"type": "boolean"
},
"excerpt": {
Expand Down
6 changes: 4 additions & 2 deletions docs/swagger/swagger.yaml
Expand Up @@ -57,13 +57,15 @@ definitions:
username:
type: string
type: object
model.Bookmark:
model.BookmarkDTO:
properties:
author:
type: string
create_archive:
description: 'TODO: migrate outside the DTO'
type: boolean
create_ebook:
description: 'TODO: migrate outside the DTO'
type: boolean
excerpt:
type: string
Expand Down Expand Up @@ -210,7 +212,7 @@ paths:
"200":
description: OK
schema:
$ref: '#/definitions/model.Bookmark'
$ref: '#/definitions/model.BookmarkDTO'
"403":
description: Token not provided/invalid
summary: Update Cache and Ebook on server.
Expand Down
2 changes: 1 addition & 1 deletion internal/http/routes/api/v1/bookmarks.go
Expand Up @@ -202,7 +202,7 @@ func (r *BookmarksAPIRoutes) deleteHandler(c *gin.Context) {
// @securityDefinitions.apikey ApiKeyAuth
// @Param payload body updateCachePayload true "Update Cache Payload"`
// @Produce json
// @Success 200 {object} model.Bookmark
// @Success 200 {object} model.BookmarkDTO
// @Failure 403 {object} nil "Token not provided/invalid"
// @Router /api/v1/bookmarks/cache [put]
func (r *BookmarksAPIRoutes) updateCache(c *gin.Context) {
Expand Down
18 changes: 0 additions & 18 deletions internal/webserver/utils.go
Expand Up @@ -4,28 +4,10 @@ import (
"html/template"
"io"
"net"
"net/http"
nurl "net/url"
"os"
"syscall"
)

func createRedirectURL(newPath, previousPath string) string {
urlQueries := nurl.Values{}
urlQueries.Set("dst", previousPath)

redirectURL, _ := nurl.Parse(newPath)
redirectURL.RawQuery = urlQueries.Encode()
return redirectURL.String()
}

func redirectPage(w http.ResponseWriter, r *http.Request, url string) {
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
w.Header().Set("Pragma", "no-cache")
w.Header().Set("Expires", "0")
http.Redirect(w, r, url, http.StatusMovedPermanently)
}

func FileExists(filePath string) bool {
info, err := os.Stat(filePath)
return err == nil && !info.IsDir()
Expand Down
3 changes: 0 additions & 3 deletions scripts/swagger_check.sh
Expand Up @@ -12,15 +12,13 @@ fi
# Check if the git tree for CWD is clean
if [ -n "$(git status docs/swagger --porcelain)" ]; then
echo "❌ git tree is not clean. Please commit all changes before running this script."
git diff
exit 1
fi

# Check swag comments
make swag-fmt
if [ -n "$(git status docs/swagger --porcelain)" ]; then
echo "❌ swag comments are not formatted. Please run 'make swag-fmt' and commit the changes."
git diff
git checkout -- docs/swagger
exit 1
fi
Expand All @@ -29,7 +27,6 @@ fi
make swagger
if [ -n "$(git status docs/swagger --porcelain)" ]; then
echo "❌ swagger documentation not updated, please run 'make swagger' and commit the changes."
git diff
git checkout -- docs/swagger
exit 1
fi