Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
fix: lint and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphg6 committed Oct 14, 2022
1 parent 5cbf02e commit c65ce71
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 25 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ jobs:
- name: "Run golint"
if: ${{ matrix.go_version == env.LATEST_GO_VERSION && matrix.os == 'ubuntu-latest'}}
run: |
make lint
go install golang.org/x/lint/golint@latest
golint -set_exit_status $1 ./...
exit $1
- name: "Run gofmt"
Expand Down
10 changes: 8 additions & 2 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,10 @@ const docTemplate = `{
},
"features": {
"type": "array",
"items": {}
"items": {
"type": "object",
"additionalProperties": true
}
},
"hasStringRule": {
"type": "boolean"
Expand All @@ -410,7 +413,10 @@ const docTemplate = `{
},
"parameters": {
"type": "array",
"items": {}
"items": {
"type": "object",
"additionalProperties": true
}
},
"rules": {
"type": "object",
Expand Down
10 changes: 8 additions & 2 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,10 @@
},
"features": {
"type": "array",
"items": {}
"items": {
"type": "object",
"additionalProperties": true
}
},
"hasStringRule": {
"type": "boolean"
Expand All @@ -403,7 +406,10 @@
},
"parameters": {
"type": "array",
"items": {}
"items": {
"type": "object",
"additionalProperties": true
}
},
"rules": {
"type": "object",
Expand Down
8 changes: 6 additions & 2 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ definitions:
description:
type: string
features:
items: {}
items:
additionalProperties: true
type: object
type: array
hasStringRule:
type: boolean
Expand All @@ -22,7 +24,9 @@ definitions:
name:
type: string
parameters:
items: {}
items:
additionalProperties: true
type: object
type: array
rules:
additionalProperties: true
Expand Down
2 changes: 2 additions & 0 deletions middlewares/middlewares.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package middlewares

import "github.com/gin-gonic/gin"

// Middleware ...
type Middleware interface {
Run()
}

// InitializeMiddlewares ...
func InitializeMiddlewares() {
NewVerifyAuthTokenMiddleware()
}
Expand Down
5 changes: 4 additions & 1 deletion middlewares/verify_auth_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/lestrrat-go/jwx/v2/jws"
)

// VerifyAuthTokenMiddleware ...
type VerifyAuthTokenMiddleware struct {
url string
ctx context.Context
Expand All @@ -22,11 +23,12 @@ type VerifyAuthTokenMiddleware struct {

var verifyAuthTokenMiddleware *VerifyAuthTokenMiddleware

// Middleware function to verify the JWT token
// VerifyAuthToken Middleware function to verify the JWT token
func VerifyAuthToken() gin.HandlerFunc {
return verifyAuthTokenMiddleware.Run()
}

// NewVerifyAuthTokenMiddleware ...
func NewVerifyAuthTokenMiddleware() {
cfg := config.GetConfig()
ctx := context.Background()
Expand All @@ -49,6 +51,7 @@ func (m *VerifyAuthTokenMiddleware) setup() {
}
}

// Run ...
func (m *VerifyAuthTokenMiddleware) Run() gin.HandlerFunc {
return func(c *gin.Context) {
token := m.extractTokenFromHeader(c)
Expand Down
17 changes: 0 additions & 17 deletions routes/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,6 @@ func SetupRoutes(router *gin.Engine) {
router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
}

// SetupRoutes define all routes
func SetupRoutesWithReturn() *gin.Engine {

router := gin.Default()

cfg := config.GetConfig()

docs.SwaggerInfo.Host = cfg.ExternalHost

homeRouter(router.Group("/"))
health.Router(router.Group("/health"))
// setup swagger docs
router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))

return router
}

// APIRoutes define all api routes
func APIRoutes(router *gin.Engine) {
// inject middleware
Expand Down

0 comments on commit c65ce71

Please sign in to comment.