feat: setup middleware

This commit is contained in:
2026-06-25 11:46:32 +02:00
parent 539c0216f5
commit a07940df20
3 changed files with 61 additions and 149 deletions

View File

@@ -85,3 +85,17 @@ func (u *UserService) GetByName(c *gin.Context, username string) (openapi.UserRe
return openapi.UserResponse{}, fmt.Errorf("Not found")
}
func (u *UserService) GetByAuthHeader(c *gin.Context) (openapi.UserResponse, error) {
apiClient := internal.GetApiClient(c)
resp, r, err := apiClient.UsersAPI.GetCurrentUserApiV1UsersCurrentGet(context.Background()).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `UserApi.GetById``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
return openapi.UserResponse{}, err
}
// response from `LoginForAccessTokenTokenPost`: Token
fmt.Fprintf(os.Stdout, "Response from `UserApi.GetById`: %v\n", resp)
return *resp, nil
}