Skip to content

Commit

Permalink
add 404 route, update env example and makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
zhendi committed Sep 11, 2024
1 parent 452d280 commit 351d4a6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
9 changes: 9 additions & 0 deletions .envrc.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,12 @@ export CSGHUB_PORTAL_STARHUB_BASE_URL=http://localhost:8080
export CSGHUB_PORTAL_STARHUB_API_KEY=f3a7b9c1d6e5f8e2a1b5d4f9e6a2b8d7c3a4e2b1d9f6e7a8d2c5a7b4c1e3f5b8a1d4f9b7d6e2f8a5d3b1e7f9c6a8b2d1e4f7d5b6e9f2a4b3c8e1d7f995hd82hf
export ENABLE_HTTPS=true
export CSGHUB_PORTAL_DATABASE_DSN=postgresql://postgres:postgres@localhost:5432/starhub_portal?sslmode=disable
export CSGHUB_PORTAL_DATABASE_DIALECT=pg
export CSGHUB_PORTAL_SIGNUP_URL=
export CSGHUB_PORTAL_LOGIN_URL=
export CSGHUB_PORTAL_S3_ENABLE_SSL=true
export CSGHUB_PORTAL_S3_REGION=
export CSGHUB_PORTAL_S3_ACCESS_KEY_ID=
export CSGHUB_PORTAL_S3_ACCESS_KEY_SECRET=
export CSGHUB_PORTAL_S3_BUCKET=
export CSGHUB_PORTAL_S3_ENDPOINT=
8 changes: 8 additions & 0 deletions internal/routes/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func Initialize(svcCtx *svc.ServiceContext) (*gin.Engine, error) {
setupStaticRouter(g)
setupViewsRouter(g, handlersRegistry)
setupApiRouter(g, handlersRegistry)
setupNotFoundRouter(g)
return g, nil
}

Expand Down Expand Up @@ -217,3 +218,10 @@ func setupApiRouter(g *gin.Engine, handlersRegistry *HandlersRegistry) {
internal_api.PUT("/users/jwt_token", handlersRegistry.FrontendHandlers.TokenHandler.RefreshToken)
internal_api.POST("/upload", handlersRegistry.FrontendHandlers.UploadHandler.Create)
}

func setupNotFoundRouter(engine *gin.Engine) {
engine.NoRoute(func(ctx *gin.Context) {
ctx.Redirect(http.StatusFound, "/errors/not-found")
ctx.AbortWithStatus(http.StatusNotFound)
})
}
4 changes: 2 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ run-backend:
build:
@echo "Building the project..."
cd frontend && yarn build
go build -o app
go build -o csghub-portal ./cmd/csghub-portal

# 清理项目
clean:
@echo "Cleaning up..."
rm -f app
rm -f csghub-portal

# 帮助信息
help:
Expand Down

0 comments on commit 351d4a6

Please sign in to comment.