Add debugger service
This commit is contained in:
parent
8d3b522ff0
commit
522e77766a
8 changed files with 68 additions and 23 deletions
13
.vscode/launch.json
vendored
Normal file
13
.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Debug golang",
|
||||
"type": "go",
|
||||
"request": "attach",
|
||||
"mode": "remote",
|
||||
"port": 4001,
|
||||
"host": "127.0.0.1"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -2,5 +2,6 @@
|
|||
|
||||
```sh
|
||||
docker compose run --rm node yarn install
|
||||
docker compose up --build
|
||||
docker compose --profile dev up --build
|
||||
docker compose --profile debug up --build
|
||||
```
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"github.com/logto-io/go/core"
|
||||
)
|
||||
|
||||
templ User(user *core.UserInfoResponse) {
|
||||
templ User(user core.UserInfoResponse) {
|
||||
<div
|
||||
x-data="{
|
||||
open: false,
|
||||
|
|
46
compose.yml
46
compose.yml
|
@ -3,8 +3,8 @@ networks:
|
|||
external: false
|
||||
|
||||
services:
|
||||
|
||||
backend:
|
||||
profiles: [dev]
|
||||
build:
|
||||
context: .
|
||||
dockerfile_inline: |
|
||||
|
@ -26,20 +26,54 @@ services:
|
|||
command: air -c .air.toml
|
||||
environment:
|
||||
- TZ=Europe/Berlin
|
||||
- PUBLIC_URL=http://localhost:4000
|
||||
- LOG_LEVEL=debug
|
||||
- TITLE=DEV
|
||||
- APP_VERSION=v0.0.1-DEV
|
||||
- PUBLIC_URL=${PUBLIC_URL}
|
||||
- TITLE=${TITLE}
|
||||
- APP_VERSION=${APP_VERSION}
|
||||
- WEATHER_KEY=${WEATHER_KEY}
|
||||
- LOGTO_ENDPOINT=${LOGTO_ENDPOINT}
|
||||
- LOGTO_APP_ID=${LOGTO_APP_ID}
|
||||
- LOGTO_APP_SECRET=${LOGTO_APP_SECRET}
|
||||
- SESSION_KEY=super-secure
|
||||
- SESSION_KEY=${SESSION_KEY}
|
||||
volumes:
|
||||
- .:/app/
|
||||
ports:
|
||||
- 4000:4000
|
||||
|
||||
backend-debug:
|
||||
profiles: [debug]
|
||||
build:
|
||||
context: .
|
||||
dockerfile_inline: |
|
||||
ARG V_GOLANG
|
||||
FROM golang:${V_GOLANG}-alpine
|
||||
RUN apk update && \
|
||||
apk upgrade && \
|
||||
apk add tzdata
|
||||
|
||||
RUN go install github.com/go-delve/delve/cmd/dlv@latest
|
||||
|
||||
WORKDIR /app
|
||||
COPY go.mod .
|
||||
COPY go.sum .
|
||||
RUN go mod download
|
||||
args:
|
||||
- V_GOLANG=${V_GOLANG}
|
||||
command: /app/scripts/debug.sh
|
||||
environment:
|
||||
- TZ=Europe/Berlin
|
||||
- PUBLIC_URL=${PUBLIC_URL}
|
||||
- APP_VERSION=${APP_VERSION}
|
||||
- WEATHER_KEY=${WEATHER_KEY}
|
||||
- LOGTO_ENDPOINT=${LOGTO_ENDPOINT}
|
||||
- LOGTO_APP_ID=${LOGTO_APP_ID}
|
||||
- LOGTO_APP_SECRET=${LOGTO_APP_SECRET}
|
||||
- SESSION_KEY=${SESSION_KEY}
|
||||
volumes:
|
||||
- .:/app/
|
||||
ports:
|
||||
- 4000:4000
|
||||
- 4001:4001
|
||||
|
||||
templ:
|
||||
profiles: [dev]
|
||||
build:
|
||||
|
|
|
@ -2,6 +2,7 @@ package handlers
|
|||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/logto-io/go/client"
|
||||
"gitlab.unjx.de/flohoss/godash/internal/env"
|
||||
"gitlab.unjx.de/flohoss/godash/services"
|
||||
"gitlab.unjx.de/flohoss/godash/views/home"
|
||||
|
@ -43,7 +44,12 @@ func (bh *AppHandler) appHandler(c echo.Context) error {
|
|||
staticSystem := bh.systemService.GetStaticInformation()
|
||||
liveSystem := bh.systemService.GetLiveInformation()
|
||||
weather := bh.weatherService.GetCurrentWeather()
|
||||
user := bh.authHandler.GetUserInfo()
|
||||
|
||||
logtoClient := client.NewLogtoClient(
|
||||
bh.authHandler.logtoConfig,
|
||||
NewSessionStorage(c),
|
||||
)
|
||||
user, _ := logtoClient.FetchUserInfo()
|
||||
|
||||
titlePage := bh.env.Title
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/logto-io/go/client"
|
||||
"github.com/logto-io/go/core"
|
||||
"gitlab.unjx.de/flohoss/godash/internal/env"
|
||||
)
|
||||
|
||||
|
@ -24,11 +23,6 @@ func NewAuthHandler(env *env.Config) *AuthHandler {
|
|||
type AuthHandler struct {
|
||||
env *env.Config
|
||||
logtoConfig *client.LogtoConfig
|
||||
userInfo *core.UserInfoResponse
|
||||
}
|
||||
|
||||
func (authHandler *AuthHandler) GetUserInfo() *core.UserInfoResponse {
|
||||
return authHandler.userInfo
|
||||
}
|
||||
|
||||
func (authHandler *AuthHandler) logtoMiddleware(next echo.HandlerFunc) echo.HandlerFunc {
|
||||
|
@ -40,13 +34,6 @@ func (authHandler *AuthHandler) logtoMiddleware(next echo.HandlerFunc) echo.Hand
|
|||
if !logtoClient.IsAuthenticated() {
|
||||
return c.Redirect(http.StatusTemporaryRedirect, "/sign-in")
|
||||
}
|
||||
if authHandler.userInfo == nil {
|
||||
info, err := logtoClient.FetchUserInfo()
|
||||
if err != nil {
|
||||
return echo.ErrInternalServerError
|
||||
}
|
||||
authHandler.userInfo = &info
|
||||
}
|
||||
return next(c)
|
||||
}
|
||||
}
|
||||
|
|
4
scripts/debug.sh
Executable file
4
scripts/debug.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/bin/sh
|
||||
|
||||
go build -gcflags="all=-N -l" -o /tmp/app
|
||||
dlv --listen=:4001 --headless=true --api-version=2 --accept-multiclient exec /tmp/app
|
|
@ -8,7 +8,7 @@ import (
|
|||
"github.com/logto-io/go/core"
|
||||
)
|
||||
|
||||
templ Home(title string, user *core.UserInfoResponse, bookmarks *services.Bookmarks, static *services.StaticInformation, live *services.LiveInformation, weather *services.OpenWeather) {
|
||||
templ Home(title string, user core.UserInfoResponse, bookmarks *services.Bookmarks, static *services.StaticInformation, live *services.LiveInformation, weather *services.OpenWeather) {
|
||||
<section class="grid gap-10">
|
||||
<div class="flex w-full justify-between items-center">
|
||||
@components.Weather(weather)
|
||||
|
|
Loading…
Reference in a new issue