Compare commits
3
Commits
961bdd81d4
...
310c8f2211
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
310c8f2211 | ||
|
|
c4ee0ce4dc | ||
|
|
2d50164213
|
No files matched your search
@@ -15,7 +15,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
POSTGRES_USER: postgres
|
POSTGRES_USER: postgres
|
||||||
POSTGRES_PASSWORD: postgres
|
POSTGRES_PASSWORD: postgres
|
||||||
POSTGRES_DB: simple_bank
|
POSTGRES_DB: api_tmpl
|
||||||
ports:
|
ports:
|
||||||
- 5432:5432
|
- 5432:5432
|
||||||
options: >-
|
options: >-
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
POSTGRES_USER: postgres
|
POSTGRES_USER: postgres
|
||||||
POSTGRES_PASSWORD: postgres
|
POSTGRES_PASSWORD: postgres
|
||||||
POSTGRES_DB: simple_bank
|
POSTGRES_DB: api_tmpl
|
||||||
ports:
|
ports:
|
||||||
- 5432:5432
|
- 5432:5432
|
||||||
options: >-
|
options: >-
|
||||||
|
|||||||
@@ -25,3 +25,9 @@ go.work.sum
|
|||||||
|
|
||||||
# env file
|
# env file
|
||||||
.env
|
.env
|
||||||
|
api.env
|
||||||
|
api_test.env
|
||||||
|
|
||||||
|
# air / build artifacts
|
||||||
|
tmp/
|
||||||
|
dbml-error.log
|
||||||
+3
-2
@@ -5,7 +5,7 @@ WORKDIR /api
|
|||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN go build -o main main.go
|
RUN go build -o main ./cmd/api
|
||||||
|
|
||||||
|
|
||||||
#Run stage
|
#Run stage
|
||||||
@@ -16,9 +16,10 @@ COPY --from=builder /api/main .
|
|||||||
COPY api.env .
|
COPY api.env .
|
||||||
COPY start.sh .
|
COPY start.sh .
|
||||||
COPY wait-for.sh .
|
COPY wait-for.sh .
|
||||||
COPY db/migrations ./db/migrations
|
COPY cmd/db/migrations ./cmd/db/migrations
|
||||||
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
EXPOSE 9090
|
||||||
|
|
||||||
CMD [ "/api/main" ]
|
CMD [ "/api/main" ]
|
||||||
ENTRYPOINT [ "/api/start.sh" ]
|
ENTRYPOINT [ "/api/start.sh" ]
|
||||||
@@ -1,171 +1,167 @@
|
|||||||
# simple_bank
|
# api_tmpl
|
||||||
|
|
||||||
simple_bank is a small example backend service in Go that demonstrates a banking-style API with:
|
A Go backend service template with a working authentication flow (register, login, email
|
||||||
- HTTP gateway (grpc-gateway) and gRPC server
|
verification, refresh tokens), built to be cloned and renamed for new projects rather than run
|
||||||
- PostgreSQL for persistent storage (SQLC generated queries)
|
as-is.
|
||||||
- Redis + Asynq for background task queue / worker processing
|
|
||||||
- Migrations via golang-migrate
|
|
||||||
- Email verification task example
|
|
||||||
|
|
||||||
This repository is intended as a reference/demo for building a production-ish Go service with background jobs.
|
Included out of the box:
|
||||||
|
- Gin-based HTTP API (`internal/handlers/http`) with an equivalent gRPC + grpc-gateway API
|
||||||
|
(`internal/handlers/grpc`, currently wired up but disabled in `main.go` — see below)
|
||||||
|
- PostgreSQL persistence via `sqlc`-generated queries (`internal/db/sqlc`)
|
||||||
|
- Redis + Asynq background task queue, with an example "send verification email" task
|
||||||
|
- PASETO/JWT auth token issuance and middleware, with role-based access control
|
||||||
|
- Migrations via `golang-migrate`
|
||||||
|
- Swagger/OpenAPI docs, served both via `swaggo` (Gin) and `grpc-gateway`'s generated spec
|
||||||
|
- Bruno API collection for manual testing (`Bruno/`)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Features
|
## Using this as a template
|
||||||
|
|
||||||
- RESTful HTTP gateway (default `:8080`) backed by gRPC (default `:9090`)
|
1. Rename the module: replace `github.com/FernandoJVideira/api_tmpl` with your own module path
|
||||||
- gRPC API and generated protobufs (uses grpc-gateway)
|
throughout the repo, and update `module` in [go.mod](go.mod).
|
||||||
- Database operations generated with `sqlc`
|
2. Copy the env templates and fill in real values:
|
||||||
- Background job dispatching and processing with `asynq` (Redis)
|
```bash
|
||||||
- Config-driven via environment variables
|
cp api.env.example api.env
|
||||||
- Example Send Verification Email background task
|
cp api_test.env.example api_test.env
|
||||||
|
```
|
||||||
|
At minimum, set a real `AUTH_TOKEN_SECRET` (32+ random characters) and, if you plan to use the
|
||||||
|
email-verification worker task, real SMTP credentials. Neither `api.env` nor `api_test.env` is
|
||||||
|
tracked in git (see `.gitignore`) — don't commit real secrets into their place.
|
||||||
|
3. If you rename the module or the gRPC service, regenerate the protobuf/gateway/swagger code:
|
||||||
|
```bash
|
||||||
|
make proto
|
||||||
|
make mock
|
||||||
|
```
|
||||||
|
This requires `protoc`, `protoc-gen-go`, `protoc-gen-go-grpc`, `protoc-gen-grpc-gateway`,
|
||||||
|
`protoc-gen-openapiv2`, and `statik` on your `PATH` (`brew install protobuf`, then
|
||||||
|
`go install` the rest — see [Makefile](Makefile) `proto` target for the exact plugins).
|
||||||
|
4. Update `PROJ_NAME` / `SERVICE_NAME` in `api.env` and `api_test.env`, and the Swagger metadata
|
||||||
|
in [cmd/api/main.go](cmd/api/main.go) (`@title`, `@description`, `@contact.email`) and
|
||||||
|
[proto/service_api_tmpl.proto](proto/service_api_tmpl.proto).
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
- Go 1.20+ (or compatible)
|
- Go 1.25+
|
||||||
- PostgreSQL
|
- PostgreSQL, Redis (or use `docker-compose.yml` for local instances)
|
||||||
- Redis
|
- [`sqlc`](https://sqlc.dev), [`golang-migrate`](https://github.com/golang-migrate/migrate),
|
||||||
- make/migrate/other CLIs (optional for migrations)
|
[`air`](https://github.com/air-verse/air) (hot reload) — all optional but expected by the
|
||||||
- Docker & Docker Compose (recommended for local dev)
|
`Makefile`
|
||||||
|
- `protoc` + Go plugins (only needed if you touch `proto/*.proto` — see above)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Quickstart (development)
|
## Quickstart (development)
|
||||||
|
|
||||||
1. Copy environment example (or use `api.env`):
|
1. Copy env files and fill in secrets (see [Using this as a template](#using-this-as-a-template)).
|
||||||
- Main variables you will want to set:
|
2. Start local Postgres + Redis:
|
||||||
- `DB_ADDR` (Postgres connection string)
|
```bash
|
||||||
- `REDIS_ADDR` (Redis host:port)
|
make up
|
||||||
- `HTTP_SERVER_ADDR` (default `:8080`)
|
```
|
||||||
- `GRPC_SERVER_ADDR` (default `:9090`)
|
|
||||||
- `ENVIRONMENT` (e.g. `development` to enable console logs)
|
|
||||||
|
|
||||||
2. Start local infra with Docker Compose (if you want local Postgres + Redis):
|
|
||||||
- (This repo includes a `docker-compose.yml` with Postgres and Redis)
|
|
||||||
- Example:
|
|
||||||
- docker-compose up -d
|
|
||||||
- Confirm Postgres and Redis are reachable at the addresses in your env.
|
|
||||||
|
|
||||||
3. Run DB migrations:
|
3. Run DB migrations:
|
||||||
- Using golang-migrate CLI (example):
|
```bash
|
||||||
- migrate -path db/migrations -database "postgres://postgres:postgres@localhost:5432/simple_bank?sslmode=disable" up
|
make migrate-up
|
||||||
- Adjust the `database` URL to match your `DB_ADDR` environment variable.
|
```
|
||||||
|
4. Run the server with hot reload:
|
||||||
|
```bash
|
||||||
|
make server
|
||||||
|
```
|
||||||
|
Or without `air`:
|
||||||
|
```bash
|
||||||
|
go run ./cmd/api
|
||||||
|
```
|
||||||
|
5. Verify:
|
||||||
|
- HTTP API: `http://localhost:8080/api/v1/...` (see routes in
|
||||||
|
[internal/handlers/http/server.go](internal/handlers/http/server.go))
|
||||||
|
- Swagger UI: `http://localhost:8080/swagger/index.html`
|
||||||
|
- Redis Commander (from `docker-compose.yml`): `http://localhost:8081`
|
||||||
|
|
||||||
4. Download dependencies and build:
|
By default `main.go` only starts the Gin HTTP server and the Asynq task processor — the gRPC
|
||||||
- go mod download
|
server and grpc-gateway (`runGrpcServer` / `runGatewayServer` in
|
||||||
- go build -o simple_bank ./...
|
[cmd/api/main.go](cmd/api/main.go)) are implemented but commented out. Uncomment them if you want
|
||||||
|
the gRPC/gateway path running alongside the Gin server.
|
||||||
5. Run the service:
|
|
||||||
- With the environment loaded (example):
|
|
||||||
- export $(cat api.env | xargs) # or use your preferred env loader
|
|
||||||
- ./simple_bank
|
|
||||||
- Running the binary will:
|
|
||||||
- start the task processor (asynq server) that consumes background jobs
|
|
||||||
- start gRPC server (on `GRPC_SERVER_ADDR`)
|
|
||||||
- start the HTTP gateway (on `HTTP_SERVER_ADDR`) in a goroutine/handler
|
|
||||||
|
|
||||||
- Alternatively, run directly with `go run`:
|
|
||||||
- go run ./main.go
|
|
||||||
|
|
||||||
6. Verify:
|
|
||||||
- HTTP gateway: http://localhost:8080 (or whatever `HTTP_SERVER_ADDR` you configure)
|
|
||||||
- gRPC: connect at the configured `GRPC_SERVER_ADDR`
|
|
||||||
- Redis dashboard / Redis Commander: if using docker-compose, a redis-commander service may be available
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Background Worker (Asynq)
|
## Background worker (Asynq)
|
||||||
|
|
||||||
- Tasks are enqueued by the app and processed by an asynq server embedded in the application.
|
- Tasks are enqueued by the app and processed by an Asynq server embedded in the same binary.
|
||||||
- The worker configuration (queues and handlers) lives under `worker/`:
|
- `internal/worker/distributer.go` — enqueues tasks (`TaskDistributor`).
|
||||||
- `worker.NewRedisTaskProcessor` creates the asynq server (`asynq.Server`) with queue weights and error handler.
|
- `internal/worker/processor.go` — consumes tasks, registers handlers, configures queue weights.
|
||||||
- `worker.NewRedisTaskDistributor` creates a client to enqueue tasks.
|
- `internal/worker/task_send_verify_email.go` — example task: sends a verification email after
|
||||||
- Example queue names: `CriticalQueue`, `DefaultQueue`.
|
user registration.
|
||||||
|
- `internal/worker/logger.go` adapts Asynq's logger to `zerolog`; edit it to change log
|
||||||
Customizing logs and formatting for asynq:
|
formatting.
|
||||||
- The asynq server can be given a custom logger via `asynq.Config.Logger`. This project includes `worker/logger.go` which adapts logs to `zerolog`. Edit `worker/logger.go` if you want to change asynq log formatting/fields.
|
|
||||||
- If you also want to capture/format other libraries' logs (for example libraries that use the standard `log` package), redirect stdlib logs to your `zerolog` instance at startup.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Environment Variables
|
## Environment variables
|
||||||
|
|
||||||
Important variables (see `api.env` for full list):
|
See `api.env.example` for the full list with defaults. Notable ones:
|
||||||
|
|
||||||
- Server:
|
- Server: `HTTP_SERVER_ADDR`, `GRPC_SERVER_ADDR`, `ENVIRONMENT`, `ALLOWED_ORIGINS`
|
||||||
- `HTTP_SERVER_ADDR` (default `:8080`)
|
- Database: `DB_ADDR`, `MIGRATIONS_URL`
|
||||||
- `GRPC_SERVER_ADDR` (default `:9090`)
|
- Redis: `REDIS_ADDR`, `REDIS_PASSWORD`, `REDIS_DB`
|
||||||
- `ENVIRONMENT` (`development` for console logs)
|
- Auth: `AUTH_TOKEN_SECRET`, `AUTH_TOKEN_MIN_KEY_SIZE`, `AUTH_TOKEN_EXP`, `REFRESH_TOKEN_EXP`,
|
||||||
- Database:
|
`AUTH_TOKEN_ISS`, `AUTH_TOKEN_AUD`
|
||||||
- `DB_DRIVER` (e.g. `pgx`)
|
- Email: `EMAIL_FROM`, `EMAIL_FROM_NAME`, `EMAIL_SMTP_PASSWORD`
|
||||||
- `DB_ADDR` (postgres connection string)
|
- Rate limiter: `RATE_LIMITER_REQS_COUNT`, `RATE_LIMITER_TIME_FRAME`, `RATE_LIMITER_ENABLED`
|
||||||
- `MIGRATIONS_URL` (e.g. `file://db/migrations`)
|
|
||||||
- Redis:
|
|
||||||
- `REDIS_ADDR` (e.g. `localhost:6379`)
|
|
||||||
- `REDIS_PASSWORD`
|
|
||||||
- `REDIS_DB`
|
|
||||||
- Auth / Tokens:
|
|
||||||
- `AUTH_TOKEN_SECRET`, `AUTH_TOKEN_EXP`, `REFRESH_TOKEN_EXP`
|
|
||||||
- Email:
|
|
||||||
- `EMAIL_FROM`, `EMAIL_SMTP_PASSWORD` (used by the worker email task)
|
|
||||||
- Rate limiter:
|
|
||||||
- `RATE_LIMITER_REQS_COUNT`, `RATE_LIMITER_TIME_FRAME`, `RATE_LIMITER_ENABLED`
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
- Unit tests:
|
```bash
|
||||||
- go test ./...
|
make test # go test -v -cover -short ./...
|
||||||
- Integration tests:
|
```
|
||||||
- Ensure Postgres and Redis are running and configured as in `api.env` before running tests that depend on external services.
|
|
||||||
|
`internal/db/sqlc` tests hit a real Postgres instance (`make up && make migrate-up` first).
|
||||||
|
Everything else runs against mocks generated with `mockgen` (`make mock`).
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Development tips
|
## Project layout
|
||||||
|
|
||||||
- To change queue weights, error handling or task handlers, edit `worker/processor.go`.
|
- `cmd/api/main.go` — application entrypoint (wires config, DB, Redis, servers)
|
||||||
- To change how tasks are enqueued, review `worker/distributer.go`.
|
- `cmd/db/migrations`, `cmd/db/query` — SQL migrations and queries consumed by `sqlc`
|
||||||
- To adjust logging format globally, modify `main.go` startup logger configuration and `worker/logger.go`.
|
- `internal/handlers/http` — Gin HTTP handlers, routes, middleware
|
||||||
- Protobuf / gRPC: regenerate stubs if you change proto files (this project uses `pb/` and generated code).
|
- `internal/handlers/grpc` — gRPC server + grpc-gateway wiring
|
||||||
|
- `internal/service` — business logic shared by both HTTP and gRPC handlers
|
||||||
|
- `internal/db/sqlc` — generated DB access layer (`Store` interface + queries)
|
||||||
|
- `internal/auth` — PASETO/JWT token makers
|
||||||
|
- `internal/security` — password hashing
|
||||||
|
- `internal/worker` — Asynq task distributor/processor
|
||||||
|
- `internal/mailer` — email sending
|
||||||
|
- `internal/config` — env-based configuration (`viper`)
|
||||||
|
- `internal/val` — request validators
|
||||||
|
- `internal/domain/role` — role constants for RBAC
|
||||||
|
- `pb/` — generated protobuf/gRPC/gateway code (regenerate via `make proto`)
|
||||||
|
- `docs/` — Swagger/OpenAPI specs and the `statik`-embedded swagger UI
|
||||||
|
- `Bruno/` — Bruno collection for manually exercising the API
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Project layout (high level)
|
## Makefile targets
|
||||||
|
|
||||||
- `main.go` — application entrypoint
|
Run `make <target>`:
|
||||||
- `api/` — Gin HTTP handlers (HTTP server)
|
|
||||||
- `gapi/` — gRPC server, grpc-gateway wiring
|
|
||||||
- `worker/` — asynq task distributor & processor, custom logger
|
|
||||||
- `db/` — SQLC generated code and migrations
|
|
||||||
- `pb/` — generated protobuf/gRPC code
|
|
||||||
- `docs/statik` — static files (swagger UI) bundled with the binary
|
|
||||||
|
|
||||||
---
|
| Target | Description |
|
||||||
|
|---|---|
|
||||||
## Troubleshooting
|
| `test` | Run unit/integration tests |
|
||||||
|
| `mock` | Regenerate mocks (`Store`, `TaskDistributor`, services) |
|
||||||
- If migrations fail:
|
| `up` / `down` / `reload` | Manage local Docker Compose infra (Postgres, Redis) |
|
||||||
- Confirm `DB_ADDR` is correct and database is reachable.
|
| `server` | Run with hot reload (`air`) |
|
||||||
- Check that `db/migrations` contains the migration files and paths are correct.
|
| `migration <name>` | Create a new migration file |
|
||||||
- If Redis jobs don't process:
|
| `migrate-up` / `migrate-down` | Apply/rollback migrations |
|
||||||
- Confirm the app can reach Redis (`REDIS_ADDR`).
|
| `sqlc` | Regenerate `internal/db/sqlc` from SQL queries |
|
||||||
- Ensure the process that runs the asynq server is running (the app starts it by default).
|
| `proto` | Regenerate `pb/`, `docs/swagger`, `docs/statik` from `proto/*.proto` |
|
||||||
- If logs appear in different formats:
|
| `dbdocs` / `dbschema` | Generate DB docs / SQL schema from `docs/db.dbml` |
|
||||||
- Redirect stdlib logs into `zerolog` or update `worker/logger.go` to include more structured context.
|
| `lint` | Run `golangci-lint` |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
- Fork and open pull requests.
|
|
||||||
- Keep changes small and focused; add/update unit tests where appropriate.
|
- Keep changes small and focused; add/update unit tests where appropriate.
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
If you'd like, I can:
|
|
||||||
- Add a short example curl snippet for the HTTP API endpoints.
|
|
||||||
- Add a sample `docker-compose` snippet and explicit commands for local development.
|
|
||||||
- Add a "Deploy" section with production tips (env secrets, TLS, metrics, etc.).
|
|
||||||
+10
-10
@@ -1,8 +1,8 @@
|
|||||||
PKG_NAME=github.com/FernandoJVideira/simple_bank
|
PKG_NAME=github.com/FernandoJVideira/api_tmpl
|
||||||
|
|
||||||
PROJ_NAME=simple_bank
|
PROJ_NAME=api_tmpl
|
||||||
|
|
||||||
SERVICE_NAME="Simple Bank"
|
SERVICE_NAME="API Template"
|
||||||
|
|
||||||
# Server Configuration
|
# Server Configuration
|
||||||
HTTP_SERVER_ADDR=:8080
|
HTTP_SERVER_ADDR=:8080
|
||||||
@@ -13,7 +13,7 @@ ENVIRONMENT=development
|
|||||||
ALLOWED_ORIGINS=https://*,http://* # TODO: Change to the actual allowed origins on production
|
ALLOWED_ORIGINS=https://*,http://* # TODO: Change to the actual allowed origins on production
|
||||||
|
|
||||||
# Database Configuration
|
# Database Configuration
|
||||||
DB_ADDR=postgres://postgres:postgres@localhost:5432/simple_bank?sslmode=disable
|
DB_ADDR=postgres://postgres:postgres@localhost:5432/api_tmpl?sslmode=disable
|
||||||
DB_USERNAME=postgres
|
DB_USERNAME=postgres
|
||||||
DB_PASSWORD=postgres
|
DB_PASSWORD=postgres
|
||||||
DB_MAX_OPEN_CONNS=30
|
DB_MAX_OPEN_CONNS=30
|
||||||
@@ -27,17 +27,17 @@ REDIS_PASSWORD=
|
|||||||
REDIS_DB=0
|
REDIS_DB=0
|
||||||
|
|
||||||
# Authentication
|
# Authentication
|
||||||
AUTH_TOKEN_SECRET=gDEt23BT2AsYzYUDu.f94mqBKLF@-w_ao
|
AUTH_TOKEN_SECRET=changeme-replace-with-a-random-secret-at-least-32-chars
|
||||||
AUTH_TOKEN_MIN_KEY_SIZE=32
|
AUTH_TOKEN_MIN_KEY_SIZE=32
|
||||||
AUTH_TOKEN_EXP=15m
|
AUTH_TOKEN_EXP=15m
|
||||||
REFRESH_TOKEN_EXP=168h
|
REFRESH_TOKEN_EXP=168h
|
||||||
AUTH_TOKEN_ISS=lkapi
|
AUTH_TOKEN_ISS=api_tmpl
|
||||||
AUTH_TOKEN_AUD=lkapi
|
AUTH_TOKEN_AUD=api_tmpl
|
||||||
|
|
||||||
# Email Configuration
|
# Email Configuration
|
||||||
EMAIL_FROM=ferna56.fv@gmail.com
|
EMAIL_FROM=changeme@example.com
|
||||||
EMAIL_FROM_NAME=Simple Bank
|
EMAIL_FROM_NAME=API Template
|
||||||
EMAIL_SMTP_PASSWORD=afyvhkfwafcedvin
|
EMAIL_SMTP_PASSWORD=changeme-smtp-app-password
|
||||||
|
|
||||||
# Rate Limiter
|
# Rate Limiter
|
||||||
RATE_LIMITER_REQS_COUNT=20
|
RATE_LIMITER_REQS_COUNT=20
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
PKG_NAME=github.com/FernandoJVideira/simple_bank
|
PKG_NAME=github.com/FernandoJVideira/api_tmpl
|
||||||
|
|
||||||
PROJ_NAME=simple_bank
|
PROJ_NAME=api_tmpl
|
||||||
|
|
||||||
SERVICE_NAME="Simple Bank"
|
SERVICE_NAME="API Template"
|
||||||
|
|
||||||
# Server Configuration
|
# Server Configuration
|
||||||
HTTP_SERVER_ADDR=:8080
|
HTTP_SERVER_ADDR=:8080
|
||||||
@@ -13,13 +13,13 @@ ENVIRONMENT=development
|
|||||||
ALLOWED_ORIGINS=https://*,http://* # TODO: Change to the actual allowed origins on production
|
ALLOWED_ORIGINS=https://*,http://* # TODO: Change to the actual allowed origins on production
|
||||||
|
|
||||||
# Database Configuration
|
# Database Configuration
|
||||||
DB_ADDR=postgres://postgres:postgres@localhost:5432/simple_bank?sslmode=disable
|
DB_ADDR=postgres://postgres:postgres@localhost:5432/api_tmpl?sslmode=disable
|
||||||
DB_USERNAME=postgres
|
DB_USERNAME=postgres
|
||||||
DB_PASSWORD=postgres
|
DB_PASSWORD=postgres
|
||||||
DB_MAX_OPEN_CONNS=30
|
DB_MAX_OPEN_CONNS=30
|
||||||
DB_MAX_IDLE_CONNS=30
|
DB_MAX_IDLE_CONNS=30
|
||||||
DB_MAX_IDLE_TIME=15m
|
DB_MAX_IDLE_TIME=15m
|
||||||
MIGRATIONS_URL=file://db/migrations
|
MIGRATIONS_URL=file://cmd/db/migrations
|
||||||
|
|
||||||
# Redis Configuration
|
# Redis Configuration
|
||||||
REDIS_ADDR=localhost:6379
|
REDIS_ADDR=localhost:6379
|
||||||
@@ -27,17 +27,17 @@ REDIS_PASSWORD=
|
|||||||
REDIS_DB=0
|
REDIS_DB=0
|
||||||
|
|
||||||
# Authentication
|
# Authentication
|
||||||
AUTH_TOKEN_SECRET=gDEt23BT2AsYzYUDu.f94mqBKLF@-w_ao
|
AUTH_TOKEN_SECRET=changeme-replace-with-a-random-secret-at-least-32-chars
|
||||||
AUTH_TOKEN_MIN_KEY_SIZE=32
|
AUTH_TOKEN_MIN_KEY_SIZE=32
|
||||||
AUTH_TOKEN_EXP=15m
|
AUTH_TOKEN_EXP=15m
|
||||||
REFRESH_TOKEN_EXP=168h
|
REFRESH_TOKEN_EXP=168h
|
||||||
AUTH_TOKEN_ISS=lkapi
|
AUTH_TOKEN_ISS=api_tmpl
|
||||||
AUTH_TOKEN_AUD=lkapi
|
AUTH_TOKEN_AUD=api_tmpl
|
||||||
|
|
||||||
# Email Configuration
|
# Email Configuration
|
||||||
EMAIL_FROM=ferna56.fv@gmail.com
|
EMAIL_FROM=changeme@example.com
|
||||||
EMAIL_FROM_NAME=Simple Bank
|
EMAIL_FROM_NAME=API Template
|
||||||
EMAIL_SMTP_PASSWORD=afyvhkfwafcedvin
|
EMAIL_SMTP_PASSWORD=changeme-smtp-app-password
|
||||||
|
|
||||||
# Rate Limiter
|
# Rate Limiter
|
||||||
RATE_LIMITER_REQS_COUNT=20
|
RATE_LIMITER_REQS_COUNT=20
|
||||||
+52
-30
@@ -15,15 +15,15 @@ import (
|
|||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
|
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/auth"
|
"github.com/FernandoJVideira/api_tmpl/internal/auth"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/config"
|
"github.com/FernandoJVideira/api_tmpl/internal/config"
|
||||||
db "github.com/FernandoJVideira/simple_bank/internal/db/sqlc"
|
db "github.com/FernandoJVideira/api_tmpl/internal/db/sqlc"
|
||||||
gapi "github.com/FernandoJVideira/simple_bank/internal/handlers/grpc"
|
gapi "github.com/FernandoJVideira/api_tmpl/internal/handlers/grpc"
|
||||||
api "github.com/FernandoJVideira/simple_bank/internal/handlers/http"
|
api "github.com/FernandoJVideira/api_tmpl/internal/handlers/http"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/mailer"
|
"github.com/FernandoJVideira/api_tmpl/internal/mailer"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/service"
|
"github.com/FernandoJVideira/api_tmpl/internal/service"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/worker"
|
"github.com/FernandoJVideira/api_tmpl/internal/worker"
|
||||||
"github.com/FernandoJVideira/simple_bank/pb"
|
"github.com/FernandoJVideira/api_tmpl/pb"
|
||||||
|
|
||||||
"github.com/golang-migrate/migrate/v4"
|
"github.com/golang-migrate/migrate/v4"
|
||||||
_ "github.com/golang-migrate/migrate/v4/database/postgres"
|
_ "github.com/golang-migrate/migrate/v4/database/postgres"
|
||||||
@@ -36,7 +36,7 @@ import (
|
|||||||
"google.golang.org/grpc/reflection"
|
"google.golang.org/grpc/reflection"
|
||||||
"google.golang.org/protobuf/encoding/protojson"
|
"google.golang.org/protobuf/encoding/protojson"
|
||||||
|
|
||||||
_ "github.com/FernandoJVideira/simple_bank/docs/statik"
|
_ "github.com/FernandoJVideira/api_tmpl/docs/statik"
|
||||||
)
|
)
|
||||||
|
|
||||||
var interruptSignals = []os.Signal{
|
var interruptSignals = []os.Signal{
|
||||||
@@ -45,13 +45,33 @@ var interruptSignals = []os.Signal{
|
|||||||
syscall.SIGINT,
|
syscall.SIGINT,
|
||||||
}
|
}
|
||||||
|
|
||||||
// @title Simple Bank API
|
type App struct {
|
||||||
|
config config.Config
|
||||||
|
store db.Store
|
||||||
|
taskDistributor worker.TaskDistributor
|
||||||
|
tokenMaker auth.Maker
|
||||||
|
userService service.UserService
|
||||||
|
authService service.AuthService
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewApp(config config.Config, store db.Store, taskDistributor worker.TaskDistributor, tokenMaker auth.Maker, userService service.UserService, authService service.AuthService) *App {
|
||||||
|
return &App{
|
||||||
|
config: config,
|
||||||
|
store: store,
|
||||||
|
taskDistributor: taskDistributor,
|
||||||
|
tokenMaker: tokenMaker,
|
||||||
|
userService: userService,
|
||||||
|
authService: authService,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// @title API Template
|
||||||
// @version 1.0
|
// @version 1.0
|
||||||
// @description API for Simple Bank application
|
// @description Backend API template service
|
||||||
// @termsOfService http://swagger.io/terms/
|
// @termsOfService http://swagger.io/terms/
|
||||||
|
|
||||||
// @contact.name API Support
|
// @contact.name API Support
|
||||||
// @contact.email support@simplebank.com
|
// @contact.email support@example.com
|
||||||
|
|
||||||
// @license.name MIT
|
// @license.name MIT
|
||||||
// @license.url https://opensource.org/licenses/MIT
|
// @license.url https://opensource.org/licenses/MIT
|
||||||
@@ -103,10 +123,12 @@ func main() {
|
|||||||
|
|
||||||
wg, ctx := errgroup.WithContext(ctx)
|
wg, ctx := errgroup.WithContext(ctx)
|
||||||
|
|
||||||
runGinServer(ctx, wg, config, store, taskDist, tokenMaker, userService, authService)
|
app := NewApp(config, store, taskDist, tokenMaker, userService, authService)
|
||||||
runTaskProcessor(ctx, wg, redisOpt, store, config)
|
|
||||||
//runGatewayServer(ctx, wg, config, store, taskDist, tokenMaker, userService, authService)
|
runGinServer(ctx, wg, app)
|
||||||
//runGrpcServer(ctx, wg, config, store, taskDist, tokenMaker, userService, authService)
|
runTaskProcessor(ctx, wg, redisOpt, app.store, app.config)
|
||||||
|
//runGatewayServer(ctx, wg, app)
|
||||||
|
//runGrpcServer(ctx, wg, app)
|
||||||
|
|
||||||
err = wg.Wait()
|
err = wg.Wait()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -144,14 +166,14 @@ func runDBMigration(migrationURL, dbSource string) {
|
|||||||
log.Info().Msg("db migrated successfully")
|
log.Info().Msg("db migrated successfully")
|
||||||
}
|
}
|
||||||
|
|
||||||
func runGinServer(ctx context.Context, wg *errgroup.Group, config config.Config, store db.Store, td worker.TaskDistributor, tokenMaker auth.Maker, userService service.UserService, authService service.AuthService) {
|
func runGinServer(ctx context.Context, wg *errgroup.Group, app *App) {
|
||||||
s, err := api.NewServer(config, store, td, tokenMaker, userService, authService)
|
s, err := api.NewServer(app.config, app.store, app.taskDistributor, app.tokenMaker, app.userService, app.authService)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Err(err).Msg("cannot create server")
|
log.Fatal().Err(err).Msg("cannot create server")
|
||||||
}
|
}
|
||||||
|
|
||||||
wg.Go(func() error {
|
wg.Go(func() error {
|
||||||
err = s.Start(config.HTTPServerAddr)
|
err = s.Start(app.config.HTTPServerAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Err(err).Msg("cannot start server:")
|
log.Fatal().Err(err).Msg("cannot start server:")
|
||||||
return err
|
return err
|
||||||
@@ -172,8 +194,8 @@ func runGinServer(ctx context.Context, wg *errgroup.Group, config config.Config,
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func runGrpcServer(ctx context.Context, wg *errgroup.Group, config config.Config, store db.Store, taskDistributor worker.TaskDistributor, tokenMaker auth.Maker, userService service.UserService, authService service.AuthService) {
|
func runGrpcServer(ctx context.Context, wg *errgroup.Group, app *App) {
|
||||||
server, err := gapi.NewServer(config, store, taskDistributor, tokenMaker, userService, authService)
|
server, err := gapi.NewServer(app.config, app.store, app.taskDistributor, app.tokenMaker, app.userService, app.authService)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Err(err).Msg("cannot create server:")
|
log.Fatal().Err(err).Msg("cannot create server:")
|
||||||
}
|
}
|
||||||
@@ -181,10 +203,10 @@ func runGrpcServer(ctx context.Context, wg *errgroup.Group, config config.Config
|
|||||||
grpcLogger := grpc.UnaryInterceptor(gapi.GrpcLogger)
|
grpcLogger := grpc.UnaryInterceptor(gapi.GrpcLogger)
|
||||||
|
|
||||||
grpcServer := grpc.NewServer(grpcLogger)
|
grpcServer := grpc.NewServer(grpcLogger)
|
||||||
pb.RegisterSimpleBankServer(grpcServer, server)
|
pb.RegisterApiTmplServer(grpcServer, server)
|
||||||
reflection.Register(grpcServer)
|
reflection.Register(grpcServer)
|
||||||
|
|
||||||
listener, err := net.Listen("tcp", config.GrpcServerAddr)
|
listener, err := net.Listen("tcp", app.config.GrpcServerAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Err(err).Msg("cannot create listener")
|
log.Fatal().Err(err).Msg("cannot create listener")
|
||||||
}
|
}
|
||||||
@@ -211,8 +233,8 @@ func runGrpcServer(ctx context.Context, wg *errgroup.Group, config config.Config
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func runGatewayServer(ctx context.Context, wg *errgroup.Group, config config.Config, store db.Store, taskDistributor worker.TaskDistributor, tokenMaker auth.Maker, userService service.UserService, authService service.AuthService) {
|
func runGatewayServer(ctx context.Context, wg *errgroup.Group, app *App) {
|
||||||
server, err := gapi.NewServer(config, store, taskDistributor, tokenMaker, userService, authService)
|
server, err := gapi.NewServer(app.config, app.store, app.taskDistributor, app.tokenMaker, app.userService, app.authService)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Err(err).Msg("cannot create server:")
|
log.Fatal().Err(err).Msg("cannot create server:")
|
||||||
}
|
}
|
||||||
@@ -228,7 +250,7 @@ func runGatewayServer(ctx context.Context, wg *errgroup.Group, config config.Con
|
|||||||
|
|
||||||
grpcMux := runtime.NewServeMux(opts)
|
grpcMux := runtime.NewServeMux(opts)
|
||||||
|
|
||||||
err = pb.RegisterSimpleBankHandlerServer(ctx, grpcMux, server)
|
err = pb.RegisterApiTmplHandlerServer(ctx, grpcMux, server)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Err(err).Msg("cannot register handler server")
|
log.Fatal().Err(err).Msg("cannot register handler server")
|
||||||
}
|
}
|
||||||
@@ -246,7 +268,7 @@ func runGatewayServer(ctx context.Context, wg *errgroup.Group, config config.Con
|
|||||||
|
|
||||||
c := cors.New(
|
c := cors.New(
|
||||||
cors.Options{
|
cors.Options{
|
||||||
AllowedOrigins: config.AllowedOrigins,
|
AllowedOrigins: app.config.AllowedOrigins,
|
||||||
AllowedMethods: []string{
|
AllowedMethods: []string{
|
||||||
http.MethodGet,
|
http.MethodGet,
|
||||||
http.MethodPost,
|
http.MethodPost,
|
||||||
@@ -262,13 +284,13 @@ func runGatewayServer(ctx context.Context, wg *errgroup.Group, config config.Con
|
|||||||
"X-CSRF-Token",
|
"X-CSRF-Token",
|
||||||
},
|
},
|
||||||
AllowCredentials: true,
|
AllowCredentials: true,
|
||||||
Debug: config.Environment == "development",
|
Debug: app.config.Environment == "development",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
handler := c.Handler(gapi.HTTPLogger(mux))
|
handler := c.Handler(gapi.HTTPLogger(mux))
|
||||||
httpServer := &http.Server{
|
httpServer := &http.Server{
|
||||||
Handler: handler,
|
Handler: handler,
|
||||||
Addr: config.HTTPServerAddr,
|
Addr: app.config.HTTPServerAddr,
|
||||||
}
|
}
|
||||||
|
|
||||||
wg.Go(func() error {
|
wg.Go(func() error {
|
||||||
|
|||||||
Whitespace-only changes.
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
Project simple_bank {
|
Project api_tmpl {
|
||||||
database_type: 'PostgreSQL'
|
database_type: 'PostgreSQL'
|
||||||
Note: '''
|
Note: '''
|
||||||
# Simple Bank Database
|
# API Template Database
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -12,7 +12,7 @@ const docTemplate = `{
|
|||||||
"termsOfService": "http://swagger.io/terms/",
|
"termsOfService": "http://swagger.io/terms/",
|
||||||
"contact": {
|
"contact": {
|
||||||
"name": "API Support",
|
"name": "API Support",
|
||||||
"email": "support@simplebank.com"
|
"email": "support@example.com"
|
||||||
},
|
},
|
||||||
"license": {
|
"license": {
|
||||||
"name": "MIT",
|
"name": "MIT",
|
||||||
@@ -159,8 +159,8 @@ var SwaggerInfo = &swag.Spec{
|
|||||||
Host: "localhost:8080",
|
Host: "localhost:8080",
|
||||||
BasePath: "/v1",
|
BasePath: "/v1",
|
||||||
Schemes: []string{"http", "https"},
|
Schemes: []string{"http", "https"},
|
||||||
Title: "Simple Bank API",
|
Title: "API Template",
|
||||||
Description: "API for Simple Bank application",
|
Description: "Backend API template service",
|
||||||
InfoInstanceName: "swagger",
|
InfoInstanceName: "swagger",
|
||||||
SwaggerTemplate: docTemplate,
|
SwaggerTemplate: docTemplate,
|
||||||
LeftDelim: "{{",
|
LeftDelim: "{{",
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
data := "PK\x03\x04\x14\x00\x08\x00\x08\x00\x0b\x03~[\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x00 \x00favicon-16x16.pngUT\x05\x00\x01\xb6\x8e+i\x00\x99\x02f\xfd\x89PNG\x0d\n\x1a\n\x00\x00\x00\x0dIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x03\x00\x00\x00(-\x0fS\x00\x00\x015PLTEb\xb14a\xb14^\xab5[\xa55W\xa07U\x9d7R\x978Q\x968/^@.]@-ZA+WA3f>4f?9o=%NC$MC$OC&MB$KB#LB!IC$KB$LB$MB%MB$NC%NC\x1cAD\x1c?E\x1fCD\x1dCD\x1fDD EC\"IC\"IC#JB'SA$LC&PA\"GB\"HC)VA+Y?$MA%MB\x146F\x154D\x152G\x113D\x125F\x101B\x0c1I\x15+@\x00$I\x003M\x0033\x00\x00\x00\x00\x00\x00\x85\xea-\x84\xe9,\x83\xe8,\x82\xe6-\x81\xe5,\x7f\xe2.\x80\xe1.}\xdd.|\xdd.v\xd20t\xd00r\xca1q\xc91p\xc81o\xc62m\xc51m\xc41l\xc32k\xc02j\xbf2i\xbe3h\xbb3h\xba3g\xb83K\x8d9J\x8a:J\x89:D\x7f;C\x7f<@y=>w=9n>8m>8n?6j?5h?3e?\x1b=E\x1b>E\x1c?E\x1c=E\x1eCE\x1fDD FD`%\x11/\x00\x00\x00;tRNS\xf4\xf4\xf5\xf5\xf6\xf5\xf7\xf6\xee\xee\xef\xf0\xea\xea\xe7\xe1\xe1\xe0\xe0\xe3\xe3\xdf\xdc\xdb\xdb\xda\xd9\xd8\xd8\xdb\xcf\xbf\xbc\xba\xac\xab\xa9\xa9\xa1\x99\x96\x94\x8e\x89\x85\x84L1$\x1e\x1d\x1f\x15\x0c\x07\n\x05\x01\x00\x07\x07\xae\xc9\x00\x00\x00\xd8IDATx\xda=\xcf\xd9.CQ\x18\x86\xe1\xcfn\x8a\x8dRi\xa9\"\x86\xb61\xcfs\xd6\xbb[\xb3\x84\x12\x1bA\x8c5\x94;u\xe0\x86\xa4\x12\xc1Z\xcdN\x9f\xa3\xff\xff\xce^\x19k.\x97Iv\x0fL-\xb9[\xc6\xac\x0fw\x94KP:N\x8c\xae\xbaac0N\xa4ih\xcd\x0e\x85\x96\xe8\xdd\xdb$\x967\x9a\xf7\xe1\xf2\x01\xeb\xf1\x1e\xda\x16T\x08\xe1}\x0bk\xe7\x0d\xc2I\xf5\x04\xf0\x1a\xe0\xbc@\xd0\xa7\x14\\\xdd\xec\x9f\x1f\x9c\x1e\x9eT. \xed\xfdI\xbfq\xff\xcb\xaf\xf9\xb5\xef\x98\xf4\xa3l\x00OE\x9c\xe7\"A\xaf\xc6C\xa8\xeebmW\xe1lB\xcb\xadp[\xc1\xba\xbb\x86\xf6E\x991\x8f\x86\xe6\x9c\xf1\x94\xca\x7f(\xf2\x99IK6p\xba\xf3\xc8\xc5\x95\x13#\xf58ke6\x9b\xec\xea\x9f\xa9\xe7\xff\x03\xcdJ9\x84\xc0\xe4\xbb\xd1\x00\x00\x00\x00IEND\xaeB`\x82\x01\x00\x00\xff\xffPK\x07\x08\\\xa1\xa9S\xa3\x02\x00\x00\x99\x02\x00\x00PK\x03\x04\x14\x00\x08\x00\x08\x00\x0b\x03~[\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x00 \x00favicon-32x32.pngUT\x05\x00\x01\xb6\x8e+i\x00t\x02\x8b\xfd\x89PNG\x0d\n\x1a\n\x00\x00\x00\x0dIHDR\x00\x00\x00 \x00\x00\x00 \x08\x03\x00\x00\x00D\xa4\x8a\xc6\x00\x00\x00\x90PLTE\x00\x00\x00\x103D\x165F\x166F\x176F\x00.:\x165F\x188E\x177F\x1a<E\x0f1@\x143D\x155F\x166F\x165F\x165E\x165F\x154F\x166F\x165F\x163G\x85\xea-\x176G!GC\x81\xe5,3f?p\xc91/^@7k>Z\xa56~\xe0.C\x80;w\xd4/_\xae59o>n\xc52?x<s\xce0&OB,YA\x1eBEe\xb74z\xd9.\x83\xe8,H\x87:J\x8a:I\x88:N\x909xo\x8d\xe5\x00\x00\x00\x15tRNS\x00\x15\xcd\xf4\xe1\x07\x99\xfe\xf8\xfe\x10 w\xc4\xa9F\x8aS\xd7\xbd-\x8ak\xf8t\x00\x00\x01~IDATx\xda\x85S\xd9v\x820\x10\x1d%\x10\"\xee\x96 kd\x07\xc5\xb6\xff\xffw-I \x14=\xf6\xbeLr\xe6\xce>\x03\x06\xf6i\xbf&\xaeK\xd6\xfb\x93\x0d\xcfX9\x16\xb2\xb0\xfa|T!C\xd7Y-\xf5[\x0b\x93<\xf0%\x82<Dk\xfb\xc7\xcbf\x87I\xe4\xcf\x10%\xb8\xdb\x18\xbdG\xd8\xcd_ g\xc4\x9b\xec 7\xe6\xc6 ':\x11{MK\xff\x05J\xba\xb6U~\x98\x0e\xff\xbe\\\xbaI\xf1(\x03X\xc9\xf0\xab9\xc6\xa3\xa6\xa5q6\xc8\xc4\x1d\x82\x1c\xa9\xfcTX\xa4\x93i\x8cWiD\x9d_\x82%\xdf~\x8c\x99q^c+\xe5\xd5\xb5\xe1\x80\xaa\xc2\x06\xc5\xa4\xef\x056\xf2q\xc3\x038L\xf5\x8f\xa3\x94\x1a\x94K\x110\x07.\xb1zb\xe7\xcf\xd0PE\x8f/@\n\xd58L\xe6\x84\x02S%\xcf\xa0\xf2\x0d\x91\xd7}\xdbeA\xc3\x85\xe0M_s\x0ce\x96\x16\xb8#!\x0b8\xbf\x0b\xce\x83\xack\xfb\xa8\x1b :\x84\xf86!\x94\xc1\x97\xd0!v:I\xca\xe6\x046&\xb9\x03\x87\xf5\xbaL\xe1\x1b`7\x95y\xc2\x9b&\xdc\x8d^ \x9f\x1ae\xbbW\xdd\xc9\xda\x10\xee\xb3V\xc3~\x1cVl\x86U`5\xc8L\x0e\xcb\xa3\xa14*\xd8 \xf5\xe0x)k\x91\xe3\x86\xa3\xee\x9aAT\xf6\xb3\x85\x01\xfb\xfc\xcf\xca\x81g\xbd_Z\x80\x83\xc5\xf2\xa5>\xa7\xc4\x83 \x1f\xe4\xfd\xe1\x00\xac.\xf8\xf6\xf4\x860g\x1c\x8e\xf7\xf1|\xbc&\xce\xf6\xd5\xf9\xff\x00\xc6\x8cF{\xbe\xb8\x05g\x00\x00\x00\x00IEND\xaeB`\x82\x01\x00\x00\xff\xffPK\x07\x08\xa0\xd3\x9fC~\x02\x00\x00t\x02\x00\x00PK\x03\x04\x14\x00\x08\x00\x08\x00\x0b\x03~[\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 \x00 \x00index.cssUT\x05\x00\x01\xb6\x8e+il\x8d\xc1\n\x830\x0c\x86\xef}\x8a\xc0n\xb2\xc2\xce\xf5i\x12M5\xac6\x10;\xa7\x8e\xbd\xfb\xa8\xee2\x18\xb9\x04\xfe\xef\xe3\x1b\xcb\x94\xe0\xe5\x00\x00HW?\xcb.y\x08@j=\x9b']\xdbc\xd3\x85-&}\x06\xf0\x93\xee~\xeeLS\"\xb4\xd9/lE:L\xbf\x9c\xdf\x02\x9cP\xeb\xde\xce5W\xd7\x04\xe2\xa8\xc6\xf5\xc3X\xd8\xfeT%\x8flR\x0e\x85\xb4\xdf\xbe\xc8\x846H\x0ep;\x1b\x84\xdd}0}\xe4>\xc0%b\xbdj|\x02\x00\x00\xff\xffPK\x07\x08\xa3k\xae\x90\x8a\x00\x00\x00\xca\x00\x00\x00PK\x03\x04\x14\x00\x08\x00\x08\x00\x0b\x03~[\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\n\x00 \x00index.htmlUT\x05\x00\x01\xb6\x8e+i\xa4\x92O\x8b\xdb0\x10\xc5\xef\xf9\x14\x13\xdde\x91\x04B\x0f\xb2/\xfdC\x0b--49\xf4([\x13{\xba\x8al\xa4q\xd6\xc9\xa7_ly aY\x02\x9b\x93\x87\xf7\xfc~\x03o\xa4\x97R\xc2\xf7\xdd\xaf\x9fph\x03D6L\x15X\x8a\x1c\xa8\xec\x99Z\x0fe\xef\xadC({r\x16\xa4,\x16z\xf9\xe5\xf7\xe7\xdd\xbf?_\xa1\xe1\xa3+\x16z\xfc\x803\xbe\xce\x05zQ,\x00t\x83\xc6\x8e\x03\x80>\"\x1b\xa8\x1a\x13\"r.\xf6\xbbo\xf2\x93\x98-&vX\xfc}6u\x8d\x01\xf6?\xb4JJr\x1d\xf9'\x08\xe8r\x11\xf9\xec06\x88,\x80\xcf\x1d\xe6\x82q`U\xc5(\xa0 x\xc8E\xa6b\xa2\xc8\x9e\xb2IW\x1f\xa0\x90\xb78\xbc\x17Line truncated
|
data := "PK\x03\x04\x14\x00\x08\x00\x08\x00\xa2\x0d\x19]\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x15\x00 \x00api_tmpl.swagger.jsonUT\x05\x00\x01\xa0\xf3\x8cj\xecYMo\xe36\x10\xbd\xfbW\x10l\x81^R\xdb\x9b\x16=\xe4\xb4\xc6b\x0blQ\x14\x8b6\xd9K\x11\x04cq$s+\x91\x0c?\x92\x18\x85\xff{A\xea\x8b\x92%\xc7\xb1\xbdX\x17\x1b\x9d\x0cr\xde\xe8qf\x1e9\x94\xff\x9d\x10B\xcd#d\x19jzE\xe8\xe5tN/\xfc\x18\x17\xa9\xa4W\xc4\xcf\x13B-\xb79\xfa\xf9\xc5\xc7\x0f\xe4\x1a\x0b\x95\x83\xc5`H\x08}@m\xb8\x14~z>\x9dO\xdf\xd4\xe3\x89\x14\x16\x12\xdbx!\x84\n(\x82\x9b\xf4\x813\xe4\x1a*SB\xa8\xd3\xb9\x9fXY\xab\xcc\xd5l\x96q\xbbr\xcbi\"\x8b\xd9\xaf\xa8\x05\x08&\x7f\xfbTbf\xa0\xf8\x9d-T\xde\x82\xb1\x00\x1e\xe0\xc6)%\xb5}\x8bOP\xa8\x1c=\x9e\x86\x15l&\x84l\xbc=\xb5\x90\x19zE\xfe\x0e\xc3[\xc4\x16\x8a_{\xd7\x0d\xe86\x80\x12)\x8c+\xb0\x05RP*\xe7 X.\xc5\xec\xb3\x91\xc2#J[\xa5%s\xc9\x9e\xb6`W\xa6 \x10\x9d=\xbc\x99%\x1a\xc1\xe2\x9d3!!\x0dA%M\x1cI\x9f5W\x14\xa0\xd7~\xd9\xef\x02\x86\xdcxL\x1d\x14B(C\x93h\xael\x95\x9c\xca\n\x88\xc0G\xe2\xfdOcc\xa9P\x07\x8a\x1fX\x14\x88\xbb\x12\xd4\xf7\xac\xd1()\x0c\xb6\xdc+/\x97\xf3yoh\x9b\xc7\x82\x18\x97$hL\xearR{\x8a\xb9\xf8\x87\x9ad\x85\x05l9#\x84~\xaf1\xf5\x14\xbf\x9b1L\xb9\xe0\x9e\xb4\x99\xa9eK\xf5\xcf\xca)\x8d\xa8\x95\xe9l~\xc7o\xa3\x0cSpy7\xbe\x83\xcc\x05q\x02\x9f\x14&\x16\x19A\xad\xa5>\xdd\x02\xb4J\xfe\xb2`\x9d\xd9\xc1z2\xc0\x9f*\xd0P\xa0E\xdd\x96\\\xf9t_\xdc\xd4\xf8R\xb2u?\xda\\\x8c\xcdh\xbcw\\\xa3/\n\xab\x1d\x1e\xb9\xc8n\x96\xee\x1d\x1a\xbb\xcfro\xdb\xd7v\x05\\\xd1\xe8\xc8\xd6?\xb7\xd5\xaf\xcd$\x8aV\xd0W.3.^&\xaf\xdf=\xe49u\x95F \x08>qc\xb9\xc8\xf6\x96X@\xf6\xbd\x9f\xa5\xc2\x1a\xa6\xaf\x02;_\x81EI\xfa\x1a\xfar\x8a\x0d\x9e_`\x93\xd5\xe8\x01v\x13@\xcfI\xac\xb2:Dc%\xb4\xef\xff,E\xd6R}U\xd9\xf9\xaa,\xce\xd2\xd7\x90\xd9\x03j\x9e\xae\xef\xea\xce\xb7\xe6M3\x1c?\xc7>\x05\x0cy\x1f0\x17\x93\xb1\xfe\xac2\x83p\x80\xfd`Hx\xc7>\x07Y \xdcr\x7f\x96*\x8b\xb8\xbe\xcal\x97\xcc8\xeb\x07\xbb\x14\xd9\xbdC\xbdKe)\xe4\xa6\xdf-\xda\xb5\n\xb7,c5\x17Y\x1f\x9cJ]\x80\x0f+\xe5\xc2\xfe\xf2s\x9c\x8e\xcd\xc5\xf3D\x13\xc9\xea+\xe9\xe9\xa9\xc6\\N&\xe7\xe6N\x1am-\x8dx\xe9P\xab\\OF\x04\xe5\xf23&\xb6Y\x9d\xbf~*\xd4\x96\xf7\xeef\xd4\x8b\xb9\nU;\xba\x9d\x93\xc9@\xc8i\xea\xf2\xfc\x8f\x03\xb1\xfd\x1djo\xa0\x02c\x1e\xa5f{c\x07\xf7\xcan\x14+\xa1\xb7\x1e\x0f\ncgd\xd7I\xee\xdb\x8d\xca\xe18\xbf\xad~\xedHv\x87&\xf9T\xf1\x8e\xd6s|\xb8\x0d\x1aS7s\xfb\xb1\x8aJ\x0f\xc2W\x86k\xf9\x0f\x8a#\xe1\xef\x9f\x14\xd7h\x16\xf6\x99\xc0\xb6\xe8\xce~\xe6\x9b\xdb\x1f-/p\x98\xa7\xc6T\xa3Y\x1dL4\xc6\x7fY\xa6\xa7\xaf\xfe\xed>\xaau\xff\xe2j\xf9f\xf7\xb88\x8a\xe7\xb8\xc7\xddt\xeb\xe6 F\xff\xcb\xc3\xeb\xdd\nD\x86\xec\x0bm\x1c\xe5\xb7\xe2\x93z\x1f)\xb0\xa1v\xb9\x0d\xcb\x8b\xf3\xc9Mp\xc8q\xf4t_J\x99#\x88h\xdd\xc3\xa5\xaf\xa5\x95K\x97.\xc4\xfa\x18>o\xab\xd7\x0eR\x19\x15a\xbd1R`,\x1c\xfa\x90\x7f\xec,\xb8+\xd3\xf6\x03\xef\x11LC\x97;B\x94\x0b\x8b\x19\xea\xb1tsa\x7f\xba\x1c.\xa4\x02\x8d\x81l\xff\x08DP\x86\x16xn\xc6\xa0\xa05t\xaf \x94[,\xfa\xf6\xe3\x91\xd8\xbd\xffD\xe9\x8f\xbcm\xb6s\xd5\xfe\x0b4\xd9L\xfe\x1b\x00PK\x07\x089;\x86\xcc\xda\x03\x00\x00\xf6\x1a\x00\x00PK\x03\x04\x14\x00\x08\x00\x08\x00\x93\x0c\x19]\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x00 \x00favicon-16x16.pngUT\x05\x00\x01\xa6\xf1\x8cj\x00\x99\x02f\xfd\x89PNG\x0d\n\x1a\n\x00\x00\x00\x0dIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x03\x00\x00\x00(-\x0fS\x00\x00\x015PLTEb\xb14a\xb14^\xab5[\xa55W\xa07U\x9d7R\x978Q\x968/^@.]@-ZA+WA3f>4f?9o=%NC$MC$OC&MB$KB#LB!IC$KB$LB$MB%MB$NC%NC\x1cAD\x1c?E\x1fCD\x1dCD\x1fDD EC\"IC\"IC#JB'SA$LC&PA\"GB\"HC)VA+Y?$MA%MB\x146F\x154D\x152G\x113D\x125F\x101B\x0c1I\x15+@\x00$I\x003M\x0033\x00\x00\x00\x00\x00\x00\x85\xea-\x84\xe9,\x83\xe8,\x82\xe6-\x81\xe5,\x7f\xe2.\x80\xe1.}\xdd.|\xdd.v\xd20t\xd00r\xca1q\xc91p\xc81o\xc62m\xc51m\xc41l\xc32k\xc02j\xbf2i\xbe3h\xbb3h\xba3g\xb83K\x8d9J\x8a:J\x89:D\x7f;C\x7f<@y=>w=9n>8m>8n?6j?5h?3e?\x1b=E\x1b>E\x1c?E\x1c=E\x1eCE\x1fDD FD`%\x11/\x00\x00\x00;tRNS\xf4\xf4\xf5\xf5\xf6\xf5\xf7\xf6\xee\xee\xef\xf0\xea\xea\xe7\xe1\xe1\xe0\xe0\xe3\xe3\xdf\xdc\xdb\xdb\xda\xd9\xd8\xd8\xdb\xcf\xbf\xbc\xba\xac\xab\xa9\xa9\xa1\x99\x96\x94\x8e\x89\x85\x84L1$\x1e\x1d\x1f\x15\x0c\x07\n\x05\x01\x00\x07\x07\xae\xc9\x00\x00\x00\xd8IDATx\xda=\xcf\xd9.CQ\x18\x86\xe1\xcfn\x8a\x8dRi\xa9\"\x86\xb61\xcfs\xd6\xbb[\xb3\x84\x12\x1bA\x8c5\x94;u\xe0\x86\xa4\x12\xc1Z\xcdN\x9f\xa3\xff\xff\xce^\x19k.\x97Iv\x0fL-\xb9[\xc6\xac\x0fw\x94KP:N\x8c\xae\xbaac0N\xa4ih\xcd\x0e\x85\x96\xe8\xdd\xdb$\x967\x9a\xf7\xe1\xf2\x01\xeb\xf1\x1e\xda\x16T\x08\xe1}\x0bk\xe7\x0d\xc2I\xf5\x04\xf0\x1a\xe0\xbc@\xd0\xa7\x14\\\xdd\xec\x9f\x1f\x9c\x1e\x9eT. \xed\xfdI\xbfq\xff\xcb\xaf\xf9\xb5\xef\x98\xf4\xa3l\x00OE\x9c\xe7\"A\xaf\xc6C\xa8\xeebmW\xe1lB\xcb\xadp[\xc1\xba\xbb\x86\xf6E\x991\x8f\x86\xe6\x9c\xf1\x94\xca\x7f(\xf2\x99IK6p\xba\xf3\xc8\xc5\x95\x13#\xf58ke6\x9b\xec\xea\x9f\xa9\xe7\xff\x03\xcdJ9\x84\xc0\xe4\xbb\xd1\x00\x00\x00\x00IEND\xaeB`\x82\x03\x00PK\x07\x08\\\xa1\xa9S\xa0\x02\x00\x00\x99\x02\x00\x00PK\x03\x04\x14\x00\x08\x00\x08\x00\x93\x0c\x19]\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x00 \x00favicon-32xLine truncated
|
||||||
fs.Register(data)
|
fs.Register(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
+3
-3
@@ -5,12 +5,12 @@
|
|||||||
],
|
],
|
||||||
"swagger": "2.0",
|
"swagger": "2.0",
|
||||||
"info": {
|
"info": {
|
||||||
"description": "API for Simple Bank application",
|
"description": "API for API Template application",
|
||||||
"title": "Simple Bank API",
|
"title": "API Template",
|
||||||
"termsOfService": "http://swagger.io/terms/",
|
"termsOfService": "http://swagger.io/terms/",
|
||||||
"contact": {
|
"contact": {
|
||||||
"name": "API Support",
|
"name": "API Support",
|
||||||
"email": "support@simplebank.com"
|
"email": "support@example.com"
|
||||||
},
|
},
|
||||||
"license": {
|
"license": {
|
||||||
"name": "MIT",
|
"name": "MIT",
|
||||||
|
|||||||
+3
-3
@@ -43,14 +43,14 @@ definitions:
|
|||||||
host: localhost:8080
|
host: localhost:8080
|
||||||
info:
|
info:
|
||||||
contact:
|
contact:
|
||||||
email: support@simplebank.com
|
email: support@example.com
|
||||||
name: API Support
|
name: API Support
|
||||||
description: API for Simple Bank application
|
description: API for API Template application
|
||||||
license:
|
license:
|
||||||
name: MIT
|
name: MIT
|
||||||
url: https://opensource.org/licenses/MIT
|
url: https://opensource.org/licenses/MIT
|
||||||
termsOfService: http://swagger.io/terms/
|
termsOfService: http://swagger.io/terms/
|
||||||
title: Simple Bank API
|
title: API Template
|
||||||
version: "1.0"
|
version: "1.0"
|
||||||
paths:
|
paths:
|
||||||
/v1/auth/register:
|
/v1/auth/register:
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
{
|
{
|
||||||
"swagger": "2.0",
|
"swagger": "2.0",
|
||||||
"info": {
|
"info": {
|
||||||
"title": "Simple Bank API",
|
"title": "API Template",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"contact": {
|
"contact": {
|
||||||
"name": "fvideira",
|
"name": "fvideira",
|
||||||
"url": "https://github.com/FernandoJVideira/simple_bank",
|
"url": "https://github.com/FernandoJVideira/api_tmpl",
|
||||||
"email": "03.pleaser-minster@icloud.com"
|
"email": "support@example.com"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tags": [
|
"tags": [
|
||||||
{
|
{
|
||||||
"name": "SimpleBank"
|
"name": "ApiTmpl"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"consumes": [
|
"consumes": [
|
||||||
@@ -24,8 +24,8 @@
|
|||||||
"/v1/create_user": {
|
"/v1/create_user": {
|
||||||
"post": {
|
"post": {
|
||||||
"summary": "Create User",
|
"summary": "Create User",
|
||||||
"description": "Create a new user in the Simple Bank system.",
|
"description": "Create a new user.",
|
||||||
"operationId": "SimpleBank_CreateUser",
|
"operationId": "ApiTmpl_CreateUser",
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "A successful response.",
|
"description": "A successful response.",
|
||||||
@@ -51,15 +51,15 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"SimpleBank"
|
"ApiTmpl"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/v1/login_user": {
|
"/v1/login_user": {
|
||||||
"post": {
|
"post": {
|
||||||
"summary": "Login User",
|
"summary": "Login User",
|
||||||
"description": "Login an existing user in the Simple Bank system.",
|
"description": "Login an existing user.",
|
||||||
"operationId": "SimpleBank_LoginUser",
|
"operationId": "ApiTmpl_LoginUser",
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "A successful response.",
|
"description": "A successful response.",
|
||||||
@@ -85,15 +85,15 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"SimpleBank"
|
"ApiTmpl"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/v1/update_user": {
|
"/v1/update_user": {
|
||||||
"patch": {
|
"patch": {
|
||||||
"summary": "Update User",
|
"summary": "Update User",
|
||||||
"description": "Update an existing user in the Simple Bank system.",
|
"description": "Update an existing user.",
|
||||||
"operationId": "SimpleBank_UpdateUser",
|
"operationId": "ApiTmpl_UpdateUser",
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "A successful response.",
|
"description": "A successful response.",
|
||||||
@@ -119,15 +119,15 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"SimpleBank"
|
"ApiTmpl"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/v1/verify_email": {
|
"/v1/verify_email": {
|
||||||
"get": {
|
"get": {
|
||||||
"summary": "Verify Email",
|
"summary": "Verify Email",
|
||||||
"description": "Verify user's email in the Simple Bank system.",
|
"description": "Verify a user's email.",
|
||||||
"operationId": "SimpleBank_VerifyEmail",
|
"operationId": "ApiTmpl_VerifyEmail",
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "A successful response.",
|
"description": "A successful response.",
|
||||||
@@ -158,7 +158,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"SimpleBank"
|
"ApiTmpl"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,7 @@ window.onload = function () {
|
|||||||
|
|
||||||
// the following lines will be replaced by docker/configurator, when it runs in a docker-container
|
// the following lines will be replaced by docker/configurator, when it runs in a docker-container
|
||||||
window.ui = SwaggerUIBundle({
|
window.ui = SwaggerUIBundle({
|
||||||
url: "simple_bank.swagger.json",
|
url: "api_tmpl.swagger.json",
|
||||||
dom_id: "#swagger-ui",
|
dom_id: "#swagger-ui",
|
||||||
deepLinking: true,
|
deepLinking: true,
|
||||||
presets: [SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset],
|
presets: [SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset],
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
module github.com/FernandoJVideira/simple_bank
|
module github.com/FernandoJVideira/api_tmpl
|
||||||
|
|
||||||
go 1.25.4
|
go 1.25.4
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/config"
|
"github.com/FernandoJVideira/api_tmpl/internal/config"
|
||||||
"github.com/golang-jwt/jwt/v5"
|
"github.com/golang-jwt/jwt/v5"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/config"
|
"github.com/FernandoJVideira/api_tmpl/internal/config"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/domain/role"
|
"github.com/FernandoJVideira/api_tmpl/internal/domain/role"
|
||||||
"github.com/FernandoJVideira/simple_bank/pkg/testutil"
|
"github.com/FernandoJVideira/api_tmpl/pkg/testutil"
|
||||||
"github.com/golang-jwt/jwt/v5"
|
"github.com/golang-jwt/jwt/v5"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"aidanwoods.dev/go-paseto"
|
"aidanwoods.dev/go-paseto"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/config"
|
"github.com/FernandoJVideira/api_tmpl/internal/config"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/config"
|
"github.com/FernandoJVideira/api_tmpl/internal/config"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/domain/role"
|
"github.com/FernandoJVideira/api_tmpl/internal/domain/role"
|
||||||
"github.com/FernandoJVideira/simple_bank/pkg/testutil"
|
"github.com/FernandoJVideira/api_tmpl/pkg/testutil"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
// Code generated by MockGen. DO NOT EDIT.
|
// Code generated by MockGen. DO NOT EDIT.
|
||||||
// Source: github.com/FernandoJVideira/simple_bank/internal/db/sqlc (interfaces: Store)
|
// Source: github.com/FernandoJVideira/api_tmpl/internal/db/sqlc (interfaces: Store)
|
||||||
//
|
//
|
||||||
// Generated by this command:
|
// Generated by this command:
|
||||||
//
|
//
|
||||||
// mockgen --package mockdb --destination internal/db/mock/store.go github.com/FernandoJVideira/simple_bank/internal/db/sqlc Store
|
// mockgen --package mockdb --destination internal/db/mock/store.go github.com/FernandoJVideira/api_tmpl/internal/db/sqlc Store
|
||||||
//
|
//
|
||||||
|
|
||||||
// Package mockdb is a generated GoMock package.
|
// Package mockdb is a generated GoMock package.
|
||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
context "context"
|
context "context"
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
|
|
||||||
db "github.com/FernandoJVideira/simple_bank/internal/db/sqlc"
|
db "github.com/FernandoJVideira/api_tmpl/internal/db/sqlc"
|
||||||
uuid "github.com/google/uuid"
|
uuid "github.com/google/uuid"
|
||||||
gomock "go.uber.org/mock/gomock"
|
gomock "go.uber.org/mock/gomock"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/config"
|
"github.com/FernandoJVideira/api_tmpl/internal/config"
|
||||||
"github.com/jackc/pgx/v5/pgxpool"
|
"github.com/jackc/pgx/v5/pgxpool"
|
||||||
_ "github.com/jackc/pgx/v5/stdlib"
|
_ "github.com/jackc/pgx/v5/stdlib"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/security"
|
"github.com/FernandoJVideira/api_tmpl/internal/security"
|
||||||
"github.com/FernandoJVideira/simple_bank/pkg/testutil"
|
"github.com/FernandoJVideira/api_tmpl/pkg/testutil"
|
||||||
"github.com/jackc/pgx/v5/pgtype"
|
"github.com/jackc/pgx/v5/pgtype"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/auth"
|
"github.com/FernandoJVideira/api_tmpl/internal/auth"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/domain/role"
|
"github.com/FernandoJVideira/api_tmpl/internal/domain/role"
|
||||||
"google.golang.org/grpc/metadata"
|
"google.golang.org/grpc/metadata"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package gapi
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
db "github.com/FernandoJVideira/simple_bank/internal/db/sqlc"
|
db "github.com/FernandoJVideira/api_tmpl/internal/db/sqlc"
|
||||||
"github.com/FernandoJVideira/simple_bank/pb"
|
"github.com/FernandoJVideira/api_tmpl/pb"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"google.golang.org/protobuf/types/known/timestamppb"
|
"google.golang.org/protobuf/types/known/timestamppb"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/auth"
|
"github.com/FernandoJVideira/api_tmpl/internal/auth"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/config"
|
"github.com/FernandoJVideira/api_tmpl/internal/config"
|
||||||
db "github.com/FernandoJVideira/simple_bank/internal/db/sqlc"
|
db "github.com/FernandoJVideira/api_tmpl/internal/db/sqlc"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/service"
|
"github.com/FernandoJVideira/api_tmpl/internal/service"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/worker"
|
"github.com/FernandoJVideira/api_tmpl/internal/worker"
|
||||||
_ "github.com/jackc/pgx/v5/stdlib"
|
_ "github.com/jackc/pgx/v5/stdlib"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"google.golang.org/grpc/metadata"
|
"google.golang.org/grpc/metadata"
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ package gapi
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
db "github.com/FernandoJVideira/simple_bank/internal/db/sqlc"
|
db "github.com/FernandoJVideira/api_tmpl/internal/db/sqlc"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/service"
|
"github.com/FernandoJVideira/api_tmpl/internal/service"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/val"
|
"github.com/FernandoJVideira/api_tmpl/internal/val"
|
||||||
"github.com/FernandoJVideira/simple_bank/pb"
|
"github.com/FernandoJVideira/api_tmpl/pb"
|
||||||
"google.golang.org/genproto/googleapis/rpc/errdetails"
|
"google.golang.org/genproto/googleapis/rpc/errdetails"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
|
|||||||
@@ -5,13 +5,13 @@ import (
|
|||||||
"database/sql"
|
"database/sql"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
db "github.com/FernandoJVideira/simple_bank/internal/db/sqlc"
|
db "github.com/FernandoJVideira/api_tmpl/internal/db/sqlc"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/domain/role"
|
"github.com/FernandoJVideira/api_tmpl/internal/domain/role"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/security"
|
"github.com/FernandoJVideira/api_tmpl/internal/security"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/service"
|
"github.com/FernandoJVideira/api_tmpl/internal/service"
|
||||||
mocksvc "github.com/FernandoJVideira/simple_bank/internal/service/mock"
|
mocksvc "github.com/FernandoJVideira/api_tmpl/internal/service/mock"
|
||||||
"github.com/FernandoJVideira/simple_bank/pb"
|
"github.com/FernandoJVideira/api_tmpl/pb"
|
||||||
"github.com/FernandoJVideira/simple_bank/pkg/testutil"
|
"github.com/FernandoJVideira/api_tmpl/pkg/testutil"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"go.uber.org/mock/gomock"
|
"go.uber.org/mock/gomock"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
db "github.com/FernandoJVideira/simple_bank/internal/db/sqlc"
|
db "github.com/FernandoJVideira/api_tmpl/internal/db/sqlc"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/service"
|
"github.com/FernandoJVideira/api_tmpl/internal/service"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/val"
|
"github.com/FernandoJVideira/api_tmpl/internal/val"
|
||||||
"github.com/FernandoJVideira/simple_bank/pb"
|
"github.com/FernandoJVideira/api_tmpl/pb"
|
||||||
"google.golang.org/genproto/googleapis/rpc/errdetails"
|
"google.golang.org/genproto/googleapis/rpc/errdetails"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
db "github.com/FernandoJVideira/simple_bank/internal/db/sqlc"
|
db "github.com/FernandoJVideira/api_tmpl/internal/db/sqlc"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/domain/role"
|
"github.com/FernandoJVideira/api_tmpl/internal/domain/role"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/service"
|
"github.com/FernandoJVideira/api_tmpl/internal/service"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/val"
|
"github.com/FernandoJVideira/api_tmpl/internal/val"
|
||||||
"github.com/FernandoJVideira/simple_bank/pb"
|
"github.com/FernandoJVideira/api_tmpl/pb"
|
||||||
"google.golang.org/genproto/googleapis/rpc/errdetails"
|
"google.golang.org/genproto/googleapis/rpc/errdetails"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
|
|||||||
@@ -5,12 +5,12 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/auth"
|
"github.com/FernandoJVideira/api_tmpl/internal/auth"
|
||||||
db "github.com/FernandoJVideira/simple_bank/internal/db/sqlc"
|
db "github.com/FernandoJVideira/api_tmpl/internal/db/sqlc"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/service"
|
"github.com/FernandoJVideira/api_tmpl/internal/service"
|
||||||
mocksvc "github.com/FernandoJVideira/simple_bank/internal/service/mock"
|
mocksvc "github.com/FernandoJVideira/api_tmpl/internal/service/mock"
|
||||||
"github.com/FernandoJVideira/simple_bank/pb"
|
"github.com/FernandoJVideira/api_tmpl/pb"
|
||||||
"github.com/FernandoJVideira/simple_bank/pkg/testutil"
|
"github.com/FernandoJVideira/api_tmpl/pkg/testutil"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"go.uber.org/mock/gomock"
|
"go.uber.org/mock/gomock"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ package gapi
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/service"
|
"github.com/FernandoJVideira/api_tmpl/internal/service"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/val"
|
"github.com/FernandoJVideira/api_tmpl/internal/val"
|
||||||
"github.com/FernandoJVideira/simple_bank/pb"
|
"github.com/FernandoJVideira/api_tmpl/pb"
|
||||||
"google.golang.org/genproto/googleapis/rpc/errdetails"
|
"google.golang.org/genproto/googleapis/rpc/errdetails"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
|
|||||||
@@ -1,24 +1,24 @@
|
|||||||
// Package gapi implements the gRPC server for the Simple Bank application.
|
// Package gapi implements the gRPC server for the API Template application.
|
||||||
package gapi
|
package gapi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/auth"
|
"github.com/FernandoJVideira/api_tmpl/internal/auth"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/config"
|
"github.com/FernandoJVideira/api_tmpl/internal/config"
|
||||||
db "github.com/FernandoJVideira/simple_bank/internal/db/sqlc"
|
db "github.com/FernandoJVideira/api_tmpl/internal/db/sqlc"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/service"
|
"github.com/FernandoJVideira/api_tmpl/internal/service"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/worker"
|
"github.com/FernandoJVideira/api_tmpl/internal/worker"
|
||||||
"github.com/FernandoJVideira/simple_bank/pb"
|
"github.com/FernandoJVideira/api_tmpl/pb"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Server serves gRPC requests for our banking service.
|
// Server serves gRPC requests for our service.
|
||||||
type Server struct {
|
type Server struct {
|
||||||
pb.UnimplementedSimpleBankServer // Embedding for forward compatibility
|
pb.UnimplementedApiTmplServer // Embedding for forward compatibility
|
||||||
config config.Config
|
config config.Config
|
||||||
store db.Store
|
store db.Store
|
||||||
tokenMaker auth.Maker
|
tokenMaker auth.Maker
|
||||||
taskDistributor worker.TaskDistributor
|
taskDistributor worker.TaskDistributor
|
||||||
userService service.UserService
|
userService service.UserService
|
||||||
authService service.AuthService
|
authService service.AuthService
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewServer creates a new gRPC server instance.
|
// NewServer creates a new gRPC server instance.
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/auth"
|
"github.com/FernandoJVideira/api_tmpl/internal/auth"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/config"
|
"github.com/FernandoJVideira/api_tmpl/internal/config"
|
||||||
db "github.com/FernandoJVideira/simple_bank/internal/db/sqlc"
|
db "github.com/FernandoJVideira/api_tmpl/internal/db/sqlc"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/service"
|
"github.com/FernandoJVideira/api_tmpl/internal/service"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/worker"
|
"github.com/FernandoJVideira/api_tmpl/internal/worker"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
_ "github.com/jackc/pgx/v5/stdlib"
|
_ "github.com/jackc/pgx/v5/stdlib"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/auth"
|
"github.com/FernandoJVideira/api_tmpl/internal/auth"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/domain/role"
|
"github.com/FernandoJVideira/api_tmpl/internal/domain/role"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/handlers/http/response"
|
"github.com/FernandoJVideira/api_tmpl/internal/handlers/http/response"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/auth"
|
"github.com/FernandoJVideira/api_tmpl/internal/auth"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/domain/role"
|
"github.com/FernandoJVideira/api_tmpl/internal/domain/role"
|
||||||
mocksvc "github.com/FernandoJVideira/simple_bank/internal/service/mock"
|
mocksvc "github.com/FernandoJVideira/api_tmpl/internal/service/mock"
|
||||||
"github.com/FernandoJVideira/simple_bank/pkg/testutil"
|
"github.com/FernandoJVideira/api_tmpl/pkg/testutil"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"go.uber.org/mock/gomock"
|
"go.uber.org/mock/gomock"
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
// Package api provides the HTTP server and routing for the banking service.
|
// Package api provides the HTTP server and routing for the service.
|
||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/auth"
|
"github.com/FernandoJVideira/api_tmpl/internal/auth"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/config"
|
"github.com/FernandoJVideira/api_tmpl/internal/config"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/domain/role"
|
"github.com/FernandoJVideira/api_tmpl/internal/domain/role"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/service"
|
"github.com/FernandoJVideira/api_tmpl/internal/service"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/worker"
|
"github.com/FernandoJVideira/api_tmpl/internal/worker"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
db "github.com/FernandoJVideira/simple_bank/internal/db/sqlc"
|
db "github.com/FernandoJVideira/api_tmpl/internal/db/sqlc"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
|
||||||
"github.com/gin-contrib/cors"
|
"github.com/gin-contrib/cors"
|
||||||
@@ -20,7 +20,7 @@ import (
|
|||||||
ginSwagger "github.com/swaggo/gin-swagger"
|
ginSwagger "github.com/swaggo/gin-swagger"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Server serves HTTP requests for our banking service.
|
// Server serves HTTP requests for our service.
|
||||||
type Server struct {
|
type Server struct {
|
||||||
config config.Config
|
config config.Config
|
||||||
store db.Store
|
store db.Store
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
db "github.com/FernandoJVideira/simple_bank/internal/db/sqlc"
|
db "github.com/FernandoJVideira/api_tmpl/internal/db/sqlc"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/handlers/http/response"
|
"github.com/FernandoJVideira/api_tmpl/internal/handlers/http/response"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/service"
|
"github.com/FernandoJVideira/api_tmpl/internal/service"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
_ "github.com/FernandoJVideira/simple_bank/docs"
|
_ "github.com/FernandoJVideira/api_tmpl/docs"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/auth"
|
"github.com/FernandoJVideira/api_tmpl/internal/auth"
|
||||||
db "github.com/FernandoJVideira/simple_bank/internal/db/sqlc"
|
db "github.com/FernandoJVideira/api_tmpl/internal/db/sqlc"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/handlers/http/response"
|
"github.com/FernandoJVideira/api_tmpl/internal/handlers/http/response"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/service"
|
"github.com/FernandoJVideira/api_tmpl/internal/service"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -12,13 +12,13 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"go.uber.org/mock/gomock"
|
"go.uber.org/mock/gomock"
|
||||||
|
|
||||||
db "github.com/FernandoJVideira/simple_bank/internal/db/sqlc"
|
db "github.com/FernandoJVideira/api_tmpl/internal/db/sqlc"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/domain/role"
|
"github.com/FernandoJVideira/api_tmpl/internal/domain/role"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/handlers/http/response"
|
"github.com/FernandoJVideira/api_tmpl/internal/handlers/http/response"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/security"
|
"github.com/FernandoJVideira/api_tmpl/internal/security"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/service"
|
"github.com/FernandoJVideira/api_tmpl/internal/service"
|
||||||
mocksvc "github.com/FernandoJVideira/simple_bank/internal/service/mock"
|
mocksvc "github.com/FernandoJVideira/api_tmpl/internal/service/mock"
|
||||||
"github.com/FernandoJVideira/simple_bank/pkg/testutil"
|
"github.com/FernandoJVideira/api_tmpl/pkg/testutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
func randomUser(t *testing.T) (user db.User, password string) {
|
func randomUser(t *testing.T) (user db.User, password string) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
// (import (
|
// (import (
|
||||||
// "github.com/FernandoJVideira/simple_bank/util"
|
// "github.com/FernandoJVideira/api_tmpl/util"
|
||||||
// "github.com/go-playground/validator/v10"
|
// "github.com/go-playground/validator/v10"
|
||||||
// )
|
// )
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package mailer
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/config"
|
"github.com/FernandoJVideira/api_tmpl/internal/config"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ func TestSendEmailWithGmail(t *testing.T) {
|
|||||||
vars := struct {
|
vars := struct {
|
||||||
ServiceName string
|
ServiceName string
|
||||||
}{
|
}{
|
||||||
ServiceName: "Simple Bank",
|
ServiceName: "API Template",
|
||||||
}
|
}
|
||||||
|
|
||||||
to := []string{"[email protected]"}
|
to := []string{"[email protected]"}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package security
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/FernandoJVideira/simple_bank/pkg/testutil"
|
"github.com/FernandoJVideira/api_tmpl/pkg/testutil"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/auth"
|
"github.com/FernandoJVideira/api_tmpl/internal/auth"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/config"
|
"github.com/FernandoJVideira/api_tmpl/internal/config"
|
||||||
db "github.com/FernandoJVideira/simple_bank/internal/db/sqlc"
|
db "github.com/FernandoJVideira/api_tmpl/internal/db/sqlc"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/security"
|
"github.com/FernandoJVideira/api_tmpl/internal/security"
|
||||||
)
|
)
|
||||||
|
|
||||||
type authService struct {
|
type authService struct {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
// Code generated by MockGen. DO NOT EDIT.
|
// Code generated by MockGen. DO NOT EDIT.
|
||||||
// Source: github.com/FernandoJVideira/simple_bank/internal/service (interfaces: UserService,AuthService)
|
// Source: github.com/FernandoJVideira/api_tmpl/internal/service (interfaces: UserService,AuthService)
|
||||||
//
|
//
|
||||||
// Generated by this command:
|
// Generated by this command:
|
||||||
//
|
//
|
||||||
// mockgen --package mocksvc --destination internal/service/mock/service.go github.com/FernandoJVideira/simple_bank/internal/service UserService,AuthService
|
// mockgen --package mocksvc --destination internal/service/mock/service.go github.com/FernandoJVideira/api_tmpl/internal/service UserService,AuthService
|
||||||
//
|
//
|
||||||
|
|
||||||
// Package mocksvc is a generated GoMock package.
|
// Package mocksvc is a generated GoMock package.
|
||||||
@@ -13,8 +13,8 @@ import (
|
|||||||
context "context"
|
context "context"
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
|
|
||||||
db "github.com/FernandoJVideira/simple_bank/internal/db/sqlc"
|
db "github.com/FernandoJVideira/api_tmpl/internal/db/sqlc"
|
||||||
service "github.com/FernandoJVideira/simple_bank/internal/service"
|
service "github.com/FernandoJVideira/api_tmpl/internal/service"
|
||||||
gomock "go.uber.org/mock/gomock"
|
gomock "go.uber.org/mock/gomock"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package service
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
db "github.com/FernandoJVideira/simple_bank/internal/db/sqlc"
|
db "github.com/FernandoJVideira/api_tmpl/internal/db/sqlc"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UserService interface {
|
type UserService interface {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package service
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
db "github.com/FernandoJVideira/simple_bank/internal/db/sqlc"
|
db "github.com/FernandoJVideira/api_tmpl/internal/db/sqlc"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
db "github.com/FernandoJVideira/simple_bank/internal/db/sqlc"
|
db "github.com/FernandoJVideira/api_tmpl/internal/db/sqlc"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/security"
|
"github.com/FernandoJVideira/api_tmpl/internal/security"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/worker"
|
"github.com/FernandoJVideira/api_tmpl/internal/worker"
|
||||||
"github.com/hibiken/asynq"
|
"github.com/hibiken/asynq"
|
||||||
"github.com/jackc/pgx/v5/pgtype"
|
"github.com/jackc/pgx/v5/pgtype"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
// Code generated by MockGen. DO NOT EDIT.
|
// Code generated by MockGen. DO NOT EDIT.
|
||||||
// Source: github.com/FernandoJVideira/simple_bank/internal/worker (interfaces: TaskDistributor)
|
// Source: github.com/FernandoJVideira/api_tmpl/internal/worker (interfaces: TaskDistributor)
|
||||||
//
|
//
|
||||||
// Generated by this command:
|
// Generated by this command:
|
||||||
//
|
//
|
||||||
// mockgen --package mockwk --destination internal/worker/mock/distributor.go github.com/FernandoJVideira/simple_bank/internal/worker TaskDistributor
|
// mockgen --package mockwk --destination internal/worker/mock/distributor.go github.com/FernandoJVideira/api_tmpl/internal/worker TaskDistributor
|
||||||
//
|
//
|
||||||
|
|
||||||
// Package mockwk is a generated GoMock package.
|
// Package mockwk is a generated GoMock package.
|
||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
context "context"
|
context "context"
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
|
|
||||||
worker "github.com/FernandoJVideira/simple_bank/internal/worker"
|
worker "github.com/FernandoJVideira/api_tmpl/internal/worker"
|
||||||
asynq "github.com/hibiken/asynq"
|
asynq "github.com/hibiken/asynq"
|
||||||
gomock "go.uber.org/mock/gomock"
|
gomock "go.uber.org/mock/gomock"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ package worker
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/config"
|
"github.com/FernandoJVideira/api_tmpl/internal/config"
|
||||||
db "github.com/FernandoJVideira/simple_bank/internal/db/sqlc"
|
db "github.com/FernandoJVideira/api_tmpl/internal/db/sqlc"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/mailer"
|
"github.com/FernandoJVideira/api_tmpl/internal/mailer"
|
||||||
"github.com/hibiken/asynq"
|
"github.com/hibiken/asynq"
|
||||||
"github.com/redis/go-redis/v9"
|
"github.com/redis/go-redis/v9"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
db "github.com/FernandoJVideira/simple_bank/internal/db/sqlc"
|
db "github.com/FernandoJVideira/api_tmpl/internal/db/sqlc"
|
||||||
"github.com/FernandoJVideira/simple_bank/internal/mailer"
|
"github.com/FernandoJVideira/api_tmpl/internal/mailer"
|
||||||
"github.com/FernandoJVideira/simple_bank/pkg/testutil"
|
"github.com/FernandoJVideira/api_tmpl/pkg/testutil"
|
||||||
"github.com/hibiken/asynq"
|
"github.com/hibiken/asynq"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.36.10
|
// protoc-gen-go v1.36.10
|
||||||
// protoc v6.33.1
|
// protoc v7.36.0
|
||||||
// source: rpc_create_user.proto
|
// source: rpc_create_user.proto
|
||||||
|
|
||||||
package pb
|
package pb
|
||||||
@@ -145,7 +145,7 @@ const file_rpc_create_user_proto_rawDesc = "" +
|
|||||||
"\x05email\x18\x03 \x01(\tR\x05email\x12\x1a\n" +
|
"\x05email\x18\x03 \x01(\tR\x05email\x12\x1a\n" +
|
||||||
"\bpassword\x18\x04 \x01(\tR\bpassword\"2\n" +
|
"\bpassword\x18\x04 \x01(\tR\bpassword\"2\n" +
|
||||||
"\x12CreateUserResponse\x12\x1c\n" +
|
"\x12CreateUserResponse\x12\x1c\n" +
|
||||||
"\x04user\x18\x01 \x01(\v2\b.pb.UserR\x04userB,Z*github.com/FernandoJVideira/simple_bank/pbb\x06proto3"
|
"\x04user\x18\x01 \x01(\v2\b.pb.UserR\x04userB)Z'github.com/FernandoJVideira/api_tmpl/pbb\x06proto3"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
file_rpc_create_user_proto_rawDescOnce sync.Once
|
file_rpc_create_user_proto_rawDescOnce sync.Once
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.36.10
|
// protoc-gen-go v1.36.10
|
||||||
// protoc v6.33.1
|
// protoc v7.36.0
|
||||||
// source: rpc_login_user.proto
|
// source: rpc_login_user.proto
|
||||||
|
|
||||||
package pb
|
package pb
|
||||||
@@ -174,7 +174,7 @@ const file_rpc_login_user_proto_rawDesc = "" +
|
|||||||
"\x17access_token_expires_at\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\x14accessTokenExpiresAt\x12#\n" +
|
"\x17access_token_expires_at\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\x14accessTokenExpiresAt\x12#\n" +
|
||||||
"\rrefresh_token\x18\x04 \x01(\tR\frefreshToken\x12S\n" +
|
"\rrefresh_token\x18\x04 \x01(\tR\frefreshToken\x12S\n" +
|
||||||
"\x18refresh_token_expires_at\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\x15refreshTokenExpiresAt\x12\x1c\n" +
|
"\x18refresh_token_expires_at\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\x15refreshTokenExpiresAt\x12\x1c\n" +
|
||||||
"\x04user\x18\x06 \x01(\v2\b.pb.UserR\x04userB,Z*github.com/FernandoJVideira/simple_bank/pbb\x06proto3"
|
"\x04user\x18\x06 \x01(\v2\b.pb.UserR\x04userB)Z'github.com/FernandoJVideira/api_tmpl/pbb\x06proto3"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
file_rpc_login_user_proto_rawDescOnce sync.Once
|
file_rpc_login_user_proto_rawDescOnce sync.Once
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.36.10
|
// protoc-gen-go v1.36.10
|
||||||
// protoc v6.33.1
|
// protoc v7.36.0
|
||||||
// source: rpc_update_user.proto
|
// source: rpc_update_user.proto
|
||||||
|
|
||||||
package pb
|
package pb
|
||||||
@@ -149,7 +149,7 @@ const file_rpc_update_user_proto_rawDesc = "" +
|
|||||||
"\x06_emailB\v\n" +
|
"\x06_emailB\v\n" +
|
||||||
"\t_password\"2\n" +
|
"\t_password\"2\n" +
|
||||||
"\x12UpdateUserResponse\x12\x1c\n" +
|
"\x12UpdateUserResponse\x12\x1c\n" +
|
||||||
"\x04user\x18\x01 \x01(\v2\b.pb.UserR\x04userB,Z*github.com/FernandoJVideira/simple_bank/pbb\x06proto3"
|
"\x04user\x18\x01 \x01(\v2\b.pb.UserR\x04userB)Z'github.com/FernandoJVideira/api_tmpl/pbb\x06proto3"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
file_rpc_update_user_proto_rawDescOnce sync.Once
|
file_rpc_update_user_proto_rawDescOnce sync.Once
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.36.10
|
// protoc-gen-go v1.36.10
|
||||||
// protoc v6.33.1
|
// protoc v7.36.0
|
||||||
// source: rpc_verify_email.proto
|
// source: rpc_verify_email.proto
|
||||||
|
|
||||||
package pb
|
package pb
|
||||||
@@ -127,7 +127,7 @@ const file_rpc_verify_email_proto_rawDesc = "" +
|
|||||||
"\x04code\x18\x02 \x01(\tR\x04code\"6\n" +
|
"\x04code\x18\x02 \x01(\tR\x04code\"6\n" +
|
||||||
"\x13VerifyEmailResponse\x12\x1f\n" +
|
"\x13VerifyEmailResponse\x12\x1f\n" +
|
||||||
"\vis_verified\x18\x01 \x01(\bR\n" +
|
"\vis_verified\x18\x01 \x01(\bR\n" +
|
||||||
"isVerifiedB,Z*github.com/FernandoJVideira/simple_bank/pbb\x06proto3"
|
"isVerifiedB)Z'github.com/FernandoJVideira/api_tmpl/pbb\x06proto3"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
file_rpc_verify_email_proto_rawDescOnce sync.Once
|
file_rpc_verify_email_proto_rawDescOnce sync.Once
|
||||||
|
|||||||
@@ -0,0 +1,92 @@
|
|||||||
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
|
// versions:
|
||||||
|
// protoc-gen-go v1.36.10
|
||||||
|
// protoc v7.36.0
|
||||||
|
// source: service_api_tmpl.proto
|
||||||
|
|
||||||
|
package pb
|
||||||
|
|
||||||
|
import (
|
||||||
|
_ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options"
|
||||||
|
_ "google.golang.org/genproto/googleapis/api/annotations"
|
||||||
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
|
reflect "reflect"
|
||||||
|
unsafe "unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Verify that this generated code is sufficiently up-to-date.
|
||||||
|
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||||
|
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||||
|
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||||
|
)
|
||||||
|
|
||||||
|
var File_service_api_tmpl_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
|
const file_service_api_tmpl_proto_rawDesc = "" +
|
||||||
|
"\n" +
|
||||||
|
"\x16service_api_tmpl.proto\x12\x02pb\x1a\x1cgoogle/api/annotations.proto\x1a\x15rpc_create_user.proto\x1a\x14rpc_login_user.proto\x1a\x15rpc_update_user.proto\x1a\x16rpc_verify_email.proto\x1a.protoc-gen-openapiv2/options/annotations.proto2\x8b\x04\n" +
|
||||||
|
"\aApiTmpl\x12{\n" +
|
||||||
|
"\n" +
|
||||||
|
"CreateUser\x12\x15.pb.CreateUserRequest\x1a\x16.pb.CreateUserResponse\">\x92A!\x12\vCreate User\x1a\x12Create a new user.\x82\xd3\xe4\x93\x02\x14:\x01*\"\x0f/v1/create_user\x12{\n" +
|
||||||
|
"\tLoginUser\x12\x14.pb.LoginUserRequest\x1a\x15.pb.LoginUserResponse\"A\x92A%\x12\n" +
|
||||||
|
"Login User\x1a\x17Login an existing user.\x82\xd3\xe4\x93\x02\x13:\x01*\"\x0e/v1/login_user\x12\x81\x01\n" +
|
||||||
|
"\vVerifyEmail\x12\x16.pb.VerifyEmailRequest\x1a\x17.pb.VerifyEmailResponse\"A\x92A&\x12\fVerify Email\x1a\x16Verify a user's email.\x82\xd3\xe4\x93\x02\x12\x12\x10/v1/verify_email\x12\x81\x01\n" +
|
||||||
|
"\n" +
|
||||||
|
"UpdateUser\x12\x15.pb.UpdateUserRequest\x1a\x16.pb.UpdateUserResponse\"D\x92A'\x12\vUpdate User\x1a\x18Update an existing user.\x82\xd3\xe4\x93\x02\x14:\x01*2\x0f/v1/update_userB\x92\x01\x92Af\x12d\n" +
|
||||||
|
"\fAPI Template\"M\n" +
|
||||||
|
"\bfvideira\x12,https://github.com/FernandoJVideira/api_tmpl\x1a\[email protected]\x050.0.1Z'github.com/FernandoJVideira/api_tmpl/pbb\x06proto3"
|
||||||
|
|
||||||
|
var file_service_api_tmpl_proto_goTypes = []any{
|
||||||
|
(*CreateUserRequest)(nil), // 0: pb.CreateUserRequest
|
||||||
|
(*LoginUserRequest)(nil), // 1: pb.LoginUserRequest
|
||||||
|
(*VerifyEmailRequest)(nil), // 2: pb.VerifyEmailRequest
|
||||||
|
(*UpdateUserRequest)(nil), // 3: pb.UpdateUserRequest
|
||||||
|
(*CreateUserResponse)(nil), // 4: pb.CreateUserResponse
|
||||||
|
(*LoginUserResponse)(nil), // 5: pb.LoginUserResponse
|
||||||
|
(*VerifyEmailResponse)(nil), // 6: pb.VerifyEmailResponse
|
||||||
|
(*UpdateUserResponse)(nil), // 7: pb.UpdateUserResponse
|
||||||
|
}
|
||||||
|
var file_service_api_tmpl_proto_depIdxs = []int32{
|
||||||
|
0, // 0: pb.ApiTmpl.CreateUser:input_type -> pb.CreateUserRequest
|
||||||
|
1, // 1: pb.ApiTmpl.LoginUser:input_type -> pb.LoginUserRequest
|
||||||
|
2, // 2: pb.ApiTmpl.VerifyEmail:input_type -> pb.VerifyEmailRequest
|
||||||
|
3, // 3: pb.ApiTmpl.UpdateUser:input_type -> pb.UpdateUserRequest
|
||||||
|
4, // 4: pb.ApiTmpl.CreateUser:output_type -> pb.CreateUserResponse
|
||||||
|
5, // 5: pb.ApiTmpl.LoginUser:output_type -> pb.LoginUserResponse
|
||||||
|
6, // 6: pb.ApiTmpl.VerifyEmail:output_type -> pb.VerifyEmailResponse
|
||||||
|
7, // 7: pb.ApiTmpl.UpdateUser:output_type -> pb.UpdateUserResponse
|
||||||
|
4, // [4:8] is the sub-list for method output_type
|
||||||
|
0, // [0:4] is the sub-list for method input_type
|
||||||
|
0, // [0:0] is the sub-list for extension type_name
|
||||||
|
0, // [0:0] is the sub-list for extension extendee
|
||||||
|
0, // [0:0] is the sub-list for field type_name
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() { file_service_api_tmpl_proto_init() }
|
||||||
|
func file_service_api_tmpl_proto_init() {
|
||||||
|
if File_service_api_tmpl_proto != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
file_rpc_create_user_proto_init()
|
||||||
|
file_rpc_login_user_proto_init()
|
||||||
|
file_rpc_update_user_proto_init()
|
||||||
|
file_rpc_verify_email_proto_init()
|
||||||
|
type x struct{}
|
||||||
|
out := protoimpl.TypeBuilder{
|
||||||
|
File: protoimpl.DescBuilder{
|
||||||
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
|
RawDescriptor: unsafe.Slice(unsafe.StringData(file_service_api_tmpl_proto_rawDesc), len(file_service_api_tmpl_proto_rawDesc)),
|
||||||
|
NumEnums: 0,
|
||||||
|
NumMessages: 0,
|
||||||
|
NumExtensions: 0,
|
||||||
|
NumServices: 1,
|
||||||
|
},
|
||||||
|
GoTypes: file_service_api_tmpl_proto_goTypes,
|
||||||
|
DependencyIndexes: file_service_api_tmpl_proto_depIdxs,
|
||||||
|
}.Build()
|
||||||
|
File_service_api_tmpl_proto = out.File
|
||||||
|
file_service_api_tmpl_proto_goTypes = nil
|
||||||
|
file_service_api_tmpl_proto_depIdxs = nil
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
|
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
|
||||||
// source: service_simple_bank.proto
|
// source: service_api_tmpl.proto
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Package pb is a reverse proxy.
|
Package pb is a reverse proxy.
|
||||||
@@ -35,7 +35,7 @@ var (
|
|||||||
_ = metadata.Join
|
_ = metadata.Join
|
||||||
)
|
)
|
||||||
|
|
||||||
func request_SimpleBank_CreateUser_0(ctx context.Context, marshaler runtime.Marshaler, client SimpleBankClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
func request_ApiTmpl_CreateUser_0(ctx context.Context, marshaler runtime.Marshaler, client ApiTmplClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
var (
|
var (
|
||||||
protoReq CreateUserRequest
|
protoReq CreateUserRequest
|
||||||
metadata runtime.ServerMetadata
|
metadata runtime.ServerMetadata
|
||||||
@@ -50,7 +50,7 @@ func request_SimpleBank_CreateUser_0(ctx context.Context, marshaler runtime.Mars
|
|||||||
return msg, metadata, err
|
return msg, metadata, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func local_request_SimpleBank_CreateUser_0(ctx context.Context, marshaler runtime.Marshaler, server SimpleBankServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
func local_request_ApiTmpl_CreateUser_0(ctx context.Context, marshaler runtime.Marshaler, server ApiTmplServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
var (
|
var (
|
||||||
protoReq CreateUserRequest
|
protoReq CreateUserRequest
|
||||||
metadata runtime.ServerMetadata
|
metadata runtime.ServerMetadata
|
||||||
@@ -62,7 +62,7 @@ func local_request_SimpleBank_CreateUser_0(ctx context.Context, marshaler runtim
|
|||||||
return msg, metadata, err
|
return msg, metadata, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func request_SimpleBank_LoginUser_0(ctx context.Context, marshaler runtime.Marshaler, client SimpleBankClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
func request_ApiTmpl_LoginUser_0(ctx context.Context, marshaler runtime.Marshaler, client ApiTmplClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
var (
|
var (
|
||||||
protoReq LoginUserRequest
|
protoReq LoginUserRequest
|
||||||
metadata runtime.ServerMetadata
|
metadata runtime.ServerMetadata
|
||||||
@@ -77,7 +77,7 @@ func request_SimpleBank_LoginUser_0(ctx context.Context, marshaler runtime.Marsh
|
|||||||
return msg, metadata, err
|
return msg, metadata, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func local_request_SimpleBank_LoginUser_0(ctx context.Context, marshaler runtime.Marshaler, server SimpleBankServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
func local_request_ApiTmpl_LoginUser_0(ctx context.Context, marshaler runtime.Marshaler, server ApiTmplServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
var (
|
var (
|
||||||
protoReq LoginUserRequest
|
protoReq LoginUserRequest
|
||||||
metadata runtime.ServerMetadata
|
metadata runtime.ServerMetadata
|
||||||
@@ -89,9 +89,9 @@ func local_request_SimpleBank_LoginUser_0(ctx context.Context, marshaler runtime
|
|||||||
return msg, metadata, err
|
return msg, metadata, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var filter_SimpleBank_VerifyEmail_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
var filter_ApiTmpl_VerifyEmail_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
||||||
|
|
||||||
func request_SimpleBank_VerifyEmail_0(ctx context.Context, marshaler runtime.Marshaler, client SimpleBankClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
func request_ApiTmpl_VerifyEmail_0(ctx context.Context, marshaler runtime.Marshaler, client ApiTmplClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
var (
|
var (
|
||||||
protoReq VerifyEmailRequest
|
protoReq VerifyEmailRequest
|
||||||
metadata runtime.ServerMetadata
|
metadata runtime.ServerMetadata
|
||||||
@@ -102,14 +102,14 @@ func request_SimpleBank_VerifyEmail_0(ctx context.Context, marshaler runtime.Mar
|
|||||||
if err := req.ParseForm(); err != nil {
|
if err := req.ParseForm(); err != nil {
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
}
|
}
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_SimpleBank_VerifyEmail_0); err != nil {
|
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ApiTmpl_VerifyEmail_0); err != nil {
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
}
|
}
|
||||||
msg, err := client.VerifyEmail(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
msg, err := client.VerifyEmail(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||||
return msg, metadata, err
|
return msg, metadata, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func local_request_SimpleBank_VerifyEmail_0(ctx context.Context, marshaler runtime.Marshaler, server SimpleBankServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
func local_request_ApiTmpl_VerifyEmail_0(ctx context.Context, marshaler runtime.Marshaler, server ApiTmplServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
var (
|
var (
|
||||||
protoReq VerifyEmailRequest
|
protoReq VerifyEmailRequest
|
||||||
metadata runtime.ServerMetadata
|
metadata runtime.ServerMetadata
|
||||||
@@ -117,14 +117,14 @@ func local_request_SimpleBank_VerifyEmail_0(ctx context.Context, marshaler runti
|
|||||||
if err := req.ParseForm(); err != nil {
|
if err := req.ParseForm(); err != nil {
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
}
|
}
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_SimpleBank_VerifyEmail_0); err != nil {
|
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ApiTmpl_VerifyEmail_0); err != nil {
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||||
}
|
}
|
||||||
msg, err := server.VerifyEmail(ctx, &protoReq)
|
msg, err := server.VerifyEmail(ctx, &protoReq)
|
||||||
return msg, metadata, err
|
return msg, metadata, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func request_SimpleBank_UpdateUser_0(ctx context.Context, marshaler runtime.Marshaler, client SimpleBankClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
func request_ApiTmpl_UpdateUser_0(ctx context.Context, marshaler runtime.Marshaler, client ApiTmplClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
var (
|
var (
|
||||||
protoReq UpdateUserRequest
|
protoReq UpdateUserRequest
|
||||||
metadata runtime.ServerMetadata
|
metadata runtime.ServerMetadata
|
||||||
@@ -139,7 +139,7 @@ func request_SimpleBank_UpdateUser_0(ctx context.Context, marshaler runtime.Mars
|
|||||||
return msg, metadata, err
|
return msg, metadata, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func local_request_SimpleBank_UpdateUser_0(ctx context.Context, marshaler runtime.Marshaler, server SimpleBankServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
func local_request_ApiTmpl_UpdateUser_0(ctx context.Context, marshaler runtime.Marshaler, server ApiTmplServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
var (
|
var (
|
||||||
protoReq UpdateUserRequest
|
protoReq UpdateUserRequest
|
||||||
metadata runtime.ServerMetadata
|
metadata runtime.ServerMetadata
|
||||||
@@ -151,99 +151,99 @@ func local_request_SimpleBank_UpdateUser_0(ctx context.Context, marshaler runtim
|
|||||||
return msg, metadata, err
|
return msg, metadata, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// RegisterSimpleBankHandlerServer registers the http handlers for service SimpleBank to "mux".
|
// RegisterApiTmplHandlerServer registers the http handlers for service ApiTmpl to "mux".
|
||||||
// UnaryRPC :call SimpleBankServer directly.
|
// UnaryRPC :call ApiTmplServer directly.
|
||||||
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
||||||
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterSimpleBankHandlerFromEndpoint instead.
|
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterApiTmplHandlerFromEndpoint instead.
|
||||||
// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call.
|
// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call.
|
||||||
func RegisterSimpleBankHandlerServer(ctx context.Context, mux *runtime.ServeMux, server SimpleBankServer) error {
|
func RegisterApiTmplHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ApiTmplServer) error {
|
||||||
mux.Handle(http.MethodPost, pattern_SimpleBank_CreateUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
mux.Handle(http.MethodPost, pattern_ApiTmpl_CreateUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
var stream runtime.ServerTransportStream
|
var stream runtime.ServerTransportStream
|
||||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/pb.SimpleBank/CreateUser", runtime.WithHTTPPathPattern("/v1/create_user"))
|
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/pb.ApiTmpl/CreateUser", runtime.WithHTTPPathPattern("/v1/create_user"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp, md, err := local_request_SimpleBank_CreateUser_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
resp, md, err := local_request_ApiTmpl_CreateUser_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
forward_SimpleBank_CreateUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
forward_ApiTmpl_CreateUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
})
|
})
|
||||||
mux.Handle(http.MethodPost, pattern_SimpleBank_LoginUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
mux.Handle(http.MethodPost, pattern_ApiTmpl_LoginUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
var stream runtime.ServerTransportStream
|
var stream runtime.ServerTransportStream
|
||||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/pb.SimpleBank/LoginUser", runtime.WithHTTPPathPattern("/v1/login_user"))
|
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/pb.ApiTmpl/LoginUser", runtime.WithHTTPPathPattern("/v1/login_user"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp, md, err := local_request_SimpleBank_LoginUser_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
resp, md, err := local_request_ApiTmpl_LoginUser_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
forward_SimpleBank_LoginUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
forward_ApiTmpl_LoginUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
})
|
})
|
||||||
mux.Handle(http.MethodGet, pattern_SimpleBank_VerifyEmail_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
mux.Handle(http.MethodGet, pattern_ApiTmpl_VerifyEmail_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
var stream runtime.ServerTransportStream
|
var stream runtime.ServerTransportStream
|
||||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/pb.SimpleBank/VerifyEmail", runtime.WithHTTPPathPattern("/v1/verify_email"))
|
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/pb.ApiTmpl/VerifyEmail", runtime.WithHTTPPathPattern("/v1/verify_email"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp, md, err := local_request_SimpleBank_VerifyEmail_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
resp, md, err := local_request_ApiTmpl_VerifyEmail_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
forward_SimpleBank_VerifyEmail_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
forward_ApiTmpl_VerifyEmail_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
})
|
})
|
||||||
mux.Handle(http.MethodPatch, pattern_SimpleBank_UpdateUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
mux.Handle(http.MethodPatch, pattern_ApiTmpl_UpdateUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
var stream runtime.ServerTransportStream
|
var stream runtime.ServerTransportStream
|
||||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/pb.SimpleBank/UpdateUser", runtime.WithHTTPPathPattern("/v1/update_user"))
|
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/pb.ApiTmpl/UpdateUser", runtime.WithHTTPPathPattern("/v1/update_user"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp, md, err := local_request_SimpleBank_UpdateUser_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
resp, md, err := local_request_ApiTmpl_UpdateUser_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
forward_SimpleBank_UpdateUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
forward_ApiTmpl_UpdateUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
})
|
})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RegisterSimpleBankHandlerFromEndpoint is same as RegisterSimpleBankHandler but
|
// RegisterApiTmplHandlerFromEndpoint is same as RegisterApiTmplHandler but
|
||||||
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
|
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
|
||||||
func RegisterSimpleBankHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
|
func RegisterApiTmplHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
|
||||||
conn, err := grpc.NewClient(endpoint, opts...)
|
conn, err := grpc.NewClient(endpoint, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -262,102 +262,102 @@ func RegisterSimpleBankHandlerFromEndpoint(ctx context.Context, mux *runtime.Ser
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}()
|
}()
|
||||||
return RegisterSimpleBankHandler(ctx, mux, conn)
|
return RegisterApiTmplHandler(ctx, mux, conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RegisterSimpleBankHandler registers the http handlers for service SimpleBank to "mux".
|
// RegisterApiTmplHandler registers the http handlers for service ApiTmpl to "mux".
|
||||||
// The handlers forward requests to the grpc endpoint over "conn".
|
// The handlers forward requests to the grpc endpoint over "conn".
|
||||||
func RegisterSimpleBankHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
|
func RegisterApiTmplHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
|
||||||
return RegisterSimpleBankHandlerClient(ctx, mux, NewSimpleBankClient(conn))
|
return RegisterApiTmplHandlerClient(ctx, mux, NewApiTmplClient(conn))
|
||||||
}
|
}
|
||||||
|
|
||||||
// RegisterSimpleBankHandlerClient registers the http handlers for service SimpleBank
|
// RegisterApiTmplHandlerClient registers the http handlers for service ApiTmpl
|
||||||
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "SimpleBankClient".
|
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ApiTmplClient".
|
||||||
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "SimpleBankClient"
|
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ApiTmplClient"
|
||||||
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
|
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
|
||||||
// "SimpleBankClient" to call the correct interceptors. This client ignores the HTTP middlewares.
|
// "ApiTmplClient" to call the correct interceptors. This client ignores the HTTP middlewares.
|
||||||
func RegisterSimpleBankHandlerClient(ctx context.Context, mux *runtime.ServeMux, client SimpleBankClient) error {
|
func RegisterApiTmplHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ApiTmplClient) error {
|
||||||
mux.Handle(http.MethodPost, pattern_SimpleBank_CreateUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
mux.Handle(http.MethodPost, pattern_ApiTmpl_CreateUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/pb.SimpleBank/CreateUser", runtime.WithHTTPPathPattern("/v1/create_user"))
|
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/pb.ApiTmpl/CreateUser", runtime.WithHTTPPathPattern("/v1/create_user"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp, md, err := request_SimpleBank_CreateUser_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
resp, md, err := request_ApiTmpl_CreateUser_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
forward_SimpleBank_CreateUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
forward_ApiTmpl_CreateUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
})
|
})
|
||||||
mux.Handle(http.MethodPost, pattern_SimpleBank_LoginUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
mux.Handle(http.MethodPost, pattern_ApiTmpl_LoginUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/pb.SimpleBank/LoginUser", runtime.WithHTTPPathPattern("/v1/login_user"))
|
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/pb.ApiTmpl/LoginUser", runtime.WithHTTPPathPattern("/v1/login_user"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp, md, err := request_SimpleBank_LoginUser_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
resp, md, err := request_ApiTmpl_LoginUser_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
forward_SimpleBank_LoginUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
forward_ApiTmpl_LoginUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
})
|
})
|
||||||
mux.Handle(http.MethodGet, pattern_SimpleBank_VerifyEmail_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
mux.Handle(http.MethodGet, pattern_ApiTmpl_VerifyEmail_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/pb.SimpleBank/VerifyEmail", runtime.WithHTTPPathPattern("/v1/verify_email"))
|
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/pb.ApiTmpl/VerifyEmail", runtime.WithHTTPPathPattern("/v1/verify_email"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp, md, err := request_SimpleBank_VerifyEmail_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
resp, md, err := request_ApiTmpl_VerifyEmail_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
forward_SimpleBank_VerifyEmail_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
forward_ApiTmpl_VerifyEmail_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
})
|
})
|
||||||
mux.Handle(http.MethodPatch, pattern_SimpleBank_UpdateUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
mux.Handle(http.MethodPatch, pattern_ApiTmpl_UpdateUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/pb.SimpleBank/UpdateUser", runtime.WithHTTPPathPattern("/v1/update_user"))
|
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/pb.ApiTmpl/UpdateUser", runtime.WithHTTPPathPattern("/v1/update_user"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp, md, err := request_SimpleBank_UpdateUser_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
resp, md, err := request_ApiTmpl_UpdateUser_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
forward_SimpleBank_UpdateUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
forward_ApiTmpl_UpdateUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
})
|
})
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
pattern_SimpleBank_CreateUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "create_user"}, ""))
|
pattern_ApiTmpl_CreateUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "create_user"}, ""))
|
||||||
pattern_SimpleBank_LoginUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "login_user"}, ""))
|
pattern_ApiTmpl_LoginUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "login_user"}, ""))
|
||||||
pattern_SimpleBank_VerifyEmail_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "verify_email"}, ""))
|
pattern_ApiTmpl_VerifyEmail_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "verify_email"}, ""))
|
||||||
pattern_SimpleBank_UpdateUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "update_user"}, ""))
|
pattern_ApiTmpl_UpdateUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "update_user"}, ""))
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
forward_SimpleBank_CreateUser_0 = runtime.ForwardResponseMessage
|
forward_ApiTmpl_CreateUser_0 = runtime.ForwardResponseMessage
|
||||||
forward_SimpleBank_LoginUser_0 = runtime.ForwardResponseMessage
|
forward_ApiTmpl_LoginUser_0 = runtime.ForwardResponseMessage
|
||||||
forward_SimpleBank_VerifyEmail_0 = runtime.ForwardResponseMessage
|
forward_ApiTmpl_VerifyEmail_0 = runtime.ForwardResponseMessage
|
||||||
forward_SimpleBank_UpdateUser_0 = runtime.ForwardResponseMessage
|
forward_ApiTmpl_UpdateUser_0 = runtime.ForwardResponseMessage
|
||||||
)
|
)
|
||||||
@@ -0,0 +1,235 @@
|
|||||||
|
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||||
|
// versions:
|
||||||
|
// - protoc-gen-go-grpc v1.6.2
|
||||||
|
// - protoc v7.36.0
|
||||||
|
// source: service_api_tmpl.proto
|
||||||
|
|
||||||
|
package pb
|
||||||
|
|
||||||
|
import (
|
||||||
|
context "context"
|
||||||
|
grpc "google.golang.org/grpc"
|
||||||
|
codes "google.golang.org/grpc/codes"
|
||||||
|
status "google.golang.org/grpc/status"
|
||||||
|
)
|
||||||
|
|
||||||
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
|
// is compatible with the grpc package it is being compiled against.
|
||||||
|
// Requires gRPC-Go v1.64.0 or later.
|
||||||
|
const _ = grpc.SupportPackageIsVersion9
|
||||||
|
|
||||||
|
const (
|
||||||
|
ApiTmpl_CreateUser_FullMethodName = "/pb.ApiTmpl/CreateUser"
|
||||||
|
ApiTmpl_LoginUser_FullMethodName = "/pb.ApiTmpl/LoginUser"
|
||||||
|
ApiTmpl_VerifyEmail_FullMethodName = "/pb.ApiTmpl/VerifyEmail"
|
||||||
|
ApiTmpl_UpdateUser_FullMethodName = "/pb.ApiTmpl/UpdateUser"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ApiTmplClient is the client API for ApiTmpl service.
|
||||||
|
//
|
||||||
|
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||||
|
type ApiTmplClient interface {
|
||||||
|
CreateUser(ctx context.Context, in *CreateUserRequest, opts ...grpc.CallOption) (*CreateUserResponse, error)
|
||||||
|
LoginUser(ctx context.Context, in *LoginUserRequest, opts ...grpc.CallOption) (*LoginUserResponse, error)
|
||||||
|
VerifyEmail(ctx context.Context, in *VerifyEmailRequest, opts ...grpc.CallOption) (*VerifyEmailResponse, error)
|
||||||
|
UpdateUser(ctx context.Context, in *UpdateUserRequest, opts ...grpc.CallOption) (*UpdateUserResponse, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type apiTmplClient struct {
|
||||||
|
cc grpc.ClientConnInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewApiTmplClient(cc grpc.ClientConnInterface) ApiTmplClient {
|
||||||
|
return &apiTmplClient{cc}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *apiTmplClient) CreateUser(ctx context.Context, in *CreateUserRequest, opts ...grpc.CallOption) (*CreateUserResponse, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(CreateUserResponse)
|
||||||
|
err := c.cc.Invoke(ctx, ApiTmpl_CreateUser_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *apiTmplClient) LoginUser(ctx context.Context, in *LoginUserRequest, opts ...grpc.CallOption) (*LoginUserResponse, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(LoginUserResponse)
|
||||||
|
err := c.cc.Invoke(ctx, ApiTmpl_LoginUser_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *apiTmplClient) VerifyEmail(ctx context.Context, in *VerifyEmailRequest, opts ...grpc.CallOption) (*VerifyEmailResponse, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(VerifyEmailResponse)
|
||||||
|
err := c.cc.Invoke(ctx, ApiTmpl_VerifyEmail_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *apiTmplClient) UpdateUser(ctx context.Context, in *UpdateUserRequest, opts ...grpc.CallOption) (*UpdateUserResponse, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(UpdateUserResponse)
|
||||||
|
err := c.cc.Invoke(ctx, ApiTmpl_UpdateUser_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ApiTmplServer is the server API for ApiTmpl service.
|
||||||
|
// All implementations must embed UnimplementedApiTmplServer
|
||||||
|
// for forward compatibility.
|
||||||
|
type ApiTmplServer interface {
|
||||||
|
CreateUser(context.Context, *CreateUserRequest) (*CreateUserResponse, error)
|
||||||
|
LoginUser(context.Context, *LoginUserRequest) (*LoginUserResponse, error)
|
||||||
|
VerifyEmail(context.Context, *VerifyEmailRequest) (*VerifyEmailResponse, error)
|
||||||
|
UpdateUser(context.Context, *UpdateUserRequest) (*UpdateUserResponse, error)
|
||||||
|
mustEmbedUnimplementedApiTmplServer()
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnimplementedApiTmplServer must be embedded to have
|
||||||
|
// forward compatible implementations.
|
||||||
|
//
|
||||||
|
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||||
|
// pointer dereference when methods are called.
|
||||||
|
type UnimplementedApiTmplServer struct{}
|
||||||
|
|
||||||
|
func (UnimplementedApiTmplServer) CreateUser(context.Context, *CreateUserRequest) (*CreateUserResponse, error) {
|
||||||
|
return nil, status.Error(codes.Unimplemented, "method CreateUser not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedApiTmplServer) LoginUser(context.Context, *LoginUserRequest) (*LoginUserResponse, error) {
|
||||||
|
return nil, status.Error(codes.Unimplemented, "method LoginUser not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedApiTmplServer) VerifyEmail(context.Context, *VerifyEmailRequest) (*VerifyEmailResponse, error) {
|
||||||
|
return nil, status.Error(codes.Unimplemented, "method VerifyEmail not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedApiTmplServer) UpdateUser(context.Context, *UpdateUserRequest) (*UpdateUserResponse, error) {
|
||||||
|
return nil, status.Error(codes.Unimplemented, "method UpdateUser not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedApiTmplServer) mustEmbedUnimplementedApiTmplServer() {}
|
||||||
|
func (UnimplementedApiTmplServer) testEmbeddedByValue() {}
|
||||||
|
|
||||||
|
// UnsafeApiTmplServer may be embedded to opt out of forward compatibility for this service.
|
||||||
|
// Use of this interface is not recommended, as added methods to ApiTmplServer will
|
||||||
|
// result in compilation errors.
|
||||||
|
type UnsafeApiTmplServer interface {
|
||||||
|
mustEmbedUnimplementedApiTmplServer()
|
||||||
|
}
|
||||||
|
|
||||||
|
func RegisterApiTmplServer(s grpc.ServiceRegistrar, srv ApiTmplServer) {
|
||||||
|
// If the following call panics, it indicates UnimplementedApiTmplServer was
|
||||||
|
// embedded by pointer and is nil. This will cause panics if an
|
||||||
|
// unimplemented method is ever invoked, so we test this at initialization
|
||||||
|
// time to prevent it from happening at runtime later due to I/O.
|
||||||
|
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||||
|
t.testEmbeddedByValue()
|
||||||
|
}
|
||||||
|
s.RegisterService(&ApiTmpl_ServiceDesc, srv)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _ApiTmpl_CreateUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(CreateUserRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(ApiTmplServer).CreateUser(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: ApiTmpl_CreateUser_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(ApiTmplServer).CreateUser(ctx, req.(*CreateUserRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _ApiTmpl_LoginUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(LoginUserRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(ApiTmplServer).LoginUser(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: ApiTmpl_LoginUser_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(ApiTmplServer).LoginUser(ctx, req.(*LoginUserRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _ApiTmpl_VerifyEmail_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(VerifyEmailRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(ApiTmplServer).VerifyEmail(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: ApiTmpl_VerifyEmail_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(ApiTmplServer).VerifyEmail(ctx, req.(*VerifyEmailRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _ApiTmpl_UpdateUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(UpdateUserRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(ApiTmplServer).UpdateUser(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: ApiTmpl_UpdateUser_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(ApiTmplServer).UpdateUser(ctx, req.(*UpdateUserRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ApiTmpl_ServiceDesc is the grpc.ServiceDesc for ApiTmpl service.
|
||||||
|
// It's only intended for direct use with grpc.RegisterService,
|
||||||
|
// and not to be introspected or modified (even as a copy)
|
||||||
|
var ApiTmpl_ServiceDesc = grpc.ServiceDesc{
|
||||||
|
ServiceName: "pb.ApiTmpl",
|
||||||
|
HandlerType: (*ApiTmplServer)(nil),
|
||||||
|
Methods: []grpc.MethodDesc{
|
||||||
|
{
|
||||||
|
MethodName: "CreateUser",
|
||||||
|
Handler: _ApiTmpl_CreateUser_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "LoginUser",
|
||||||
|
Handler: _ApiTmpl_LoginUser_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "VerifyEmail",
|
||||||
|
Handler: _ApiTmpl_VerifyEmail_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "UpdateUser",
|
||||||
|
Handler: _ApiTmpl_UpdateUser_Handler,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Streams: []grpc.StreamDesc{},
|
||||||
|
Metadata: "service_api_tmpl.proto",
|
||||||
|
}
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// protoc-gen-go v1.36.10
|
|
||||||
// protoc v6.33.1
|
|
||||||
// source: service_simple_bank.proto
|
|
||||||
|
|
||||||
package pb
|
|
||||||
|
|
||||||
import (
|
|
||||||
_ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options"
|
|
||||||
_ "google.golang.org/genproto/googleapis/api/annotations"
|
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
||||||
reflect "reflect"
|
|
||||||
unsafe "unsafe"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
// Verify that this generated code is sufficiently up-to-date.
|
|
||||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
|
||||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
|
||||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
|
||||||
)
|
|
||||||
|
|
||||||
var File_service_simple_bank_proto protoreflect.FileDescriptor
|
|
||||||
|
|
||||||
const file_service_simple_bank_proto_rawDesc = "" +
|
|
||||||
"\n" +
|
|
||||||
"\x19service_simple_bank.proto\x12\x02pb\x1a\x1cgoogle/api/annotations.proto\x1a\x15rpc_create_user.proto\x1a\x14rpc_login_user.proto\x1a\x15rpc_update_user.proto\x1a\x16rpc_verify_email.proto\x1a.protoc-gen-openapiv2/options/annotations.proto2\xf6\x04\n" +
|
|
||||||
"\n" +
|
|
||||||
"SimpleBank\x12\x95\x01\n" +
|
|
||||||
"\n" +
|
|
||||||
"CreateUser\x12\x15.pb.CreateUserRequest\x1a\x16.pb.CreateUserResponse\"X\x92A;\x12\vCreate User\x1a,Create a new user in the Simple Bank system.\x82\xd3\xe4\x93\x02\x14:\x01*\"\x0f/v1/create_user\x12\x95\x01\n" +
|
|
||||||
"\tLoginUser\x12\x14.pb.LoginUserRequest\x1a\x15.pb.LoginUserResponse\"[\x92A?\x12\n" +
|
|
||||||
"Login User\x1a1Login an existing user in the Simple Bank system.\x82\xd3\xe4\x93\x02\x13:\x01*\"\x0e/v1/login_user\x12\x99\x01\n" +
|
|
||||||
"\vVerifyEmail\x12\x16.pb.VerifyEmailRequest\x1a\x17.pb.VerifyEmailResponse\"Y\x92A>\x12\fVerify Email\x1a.Verify user's email in the Simple Bank system.\x82\xd3\xe4\x93\x02\x12\x12\x10/v1/verify_email\x12\x9b\x01\n" +
|
|
||||||
"\n" +
|
|
||||||
"UpdateUser\x12\x15.pb.UpdateUserRequest\x1a\x16.pb.UpdateUserResponse\"^\x92AA\x12\vUpdate User\x1a2Update an existing user in the Simple Bank system.\x82\xd3\xe4\x93\x02\x14:\x01*2\x0f/v1/update_userB\xa5\x01\x92Av\x12t\n" +
|
|
||||||
"\x0fSimple Bank API\"Z\n" +
|
|
||||||
"\bfvideira\x12/https://github.com/FernandoJVideira/simple_bank\x1a\[email protected]\x050.0.1Z*github.com/FernandoJVideira/simple_bank/pbb\x06proto3"
|
|
||||||
|
|
||||||
var file_service_simple_bank_proto_goTypes = []any{
|
|
||||||
(*CreateUserRequest)(nil), // 0: pb.CreateUserRequest
|
|
||||||
(*LoginUserRequest)(nil), // 1: pb.LoginUserRequest
|
|
||||||
(*VerifyEmailRequest)(nil), // 2: pb.VerifyEmailRequest
|
|
||||||
(*UpdateUserRequest)(nil), // 3: pb.UpdateUserRequest
|
|
||||||
(*CreateUserResponse)(nil), // 4: pb.CreateUserResponse
|
|
||||||
(*LoginUserResponse)(nil), // 5: pb.LoginUserResponse
|
|
||||||
(*VerifyEmailResponse)(nil), // 6: pb.VerifyEmailResponse
|
|
||||||
(*UpdateUserResponse)(nil), // 7: pb.UpdateUserResponse
|
|
||||||
}
|
|
||||||
var file_service_simple_bank_proto_depIdxs = []int32{
|
|
||||||
0, // 0: pb.SimpleBank.CreateUser:input_type -> pb.CreateUserRequest
|
|
||||||
1, // 1: pb.SimpleBank.LoginUser:input_type -> pb.LoginUserRequest
|
|
||||||
2, // 2: pb.SimpleBank.VerifyEmail:input_type -> pb.VerifyEmailRequest
|
|
||||||
3, // 3: pb.SimpleBank.UpdateUser:input_type -> pb.UpdateUserRequest
|
|
||||||
4, // 4: pb.SimpleBank.CreateUser:output_type -> pb.CreateUserResponse
|
|
||||||
5, // 5: pb.SimpleBank.LoginUser:output_type -> pb.LoginUserResponse
|
|
||||||
6, // 6: pb.SimpleBank.VerifyEmail:output_type -> pb.VerifyEmailResponse
|
|
||||||
7, // 7: pb.SimpleBank.UpdateUser:output_type -> pb.UpdateUserResponse
|
|
||||||
4, // [4:8] is the sub-list for method output_type
|
|
||||||
0, // [0:4] is the sub-list for method input_type
|
|
||||||
0, // [0:0] is the sub-list for extension type_name
|
|
||||||
0, // [0:0] is the sub-list for extension extendee
|
|
||||||
0, // [0:0] is the sub-list for field type_name
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() { file_service_simple_bank_proto_init() }
|
|
||||||
func file_service_simple_bank_proto_init() {
|
|
||||||
if File_service_simple_bank_proto != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
file_rpc_create_user_proto_init()
|
|
||||||
file_rpc_login_user_proto_init()
|
|
||||||
file_rpc_update_user_proto_init()
|
|
||||||
file_rpc_verify_email_proto_init()
|
|
||||||
type x struct{}
|
|
||||||
out := protoimpl.TypeBuilder{
|
|
||||||
File: protoimpl.DescBuilder{
|
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
|
||||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_service_simple_bank_proto_rawDesc), len(file_service_simple_bank_proto_rawDesc)),
|
|
||||||
NumEnums: 0,
|
|
||||||
NumMessages: 0,
|
|
||||||
NumExtensions: 0,
|
|
||||||
NumServices: 1,
|
|
||||||
},
|
|
||||||
GoTypes: file_service_simple_bank_proto_goTypes,
|
|
||||||
DependencyIndexes: file_service_simple_bank_proto_depIdxs,
|
|
||||||
}.Build()
|
|
||||||
File_service_simple_bank_proto = out.File
|
|
||||||
file_service_simple_bank_proto_goTypes = nil
|
|
||||||
file_service_simple_bank_proto_depIdxs = nil
|
|
||||||
}
|
|
||||||
@@ -1,235 +0,0 @@
|
|||||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// - protoc-gen-go-grpc v1.5.1
|
|
||||||
// - protoc v6.33.1
|
|
||||||
// source: service_simple_bank.proto
|
|
||||||
|
|
||||||
package pb
|
|
||||||
|
|
||||||
import (
|
|
||||||
context "context"
|
|
||||||
grpc "google.golang.org/grpc"
|
|
||||||
codes "google.golang.org/grpc/codes"
|
|
||||||
status "google.golang.org/grpc/status"
|
|
||||||
)
|
|
||||||
|
|
||||||
// This is a compile-time assertion to ensure that this generated file
|
|
||||||
// is compatible with the grpc package it is being compiled against.
|
|
||||||
// Requires gRPC-Go v1.64.0 or later.
|
|
||||||
const _ = grpc.SupportPackageIsVersion9
|
|
||||||
|
|
||||||
const (
|
|
||||||
SimpleBank_CreateUser_FullMethodName = "/pb.SimpleBank/CreateUser"
|
|
||||||
SimpleBank_LoginUser_FullMethodName = "/pb.SimpleBank/LoginUser"
|
|
||||||
SimpleBank_VerifyEmail_FullMethodName = "/pb.SimpleBank/VerifyEmail"
|
|
||||||
SimpleBank_UpdateUser_FullMethodName = "/pb.SimpleBank/UpdateUser"
|
|
||||||
)
|
|
||||||
|
|
||||||
// SimpleBankClient is the client API for SimpleBank service.
|
|
||||||
//
|
|
||||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
|
||||||
type SimpleBankClient interface {
|
|
||||||
CreateUser(ctx context.Context, in *CreateUserRequest, opts ...grpc.CallOption) (*CreateUserResponse, error)
|
|
||||||
LoginUser(ctx context.Context, in *LoginUserRequest, opts ...grpc.CallOption) (*LoginUserResponse, error)
|
|
||||||
VerifyEmail(ctx context.Context, in *VerifyEmailRequest, opts ...grpc.CallOption) (*VerifyEmailResponse, error)
|
|
||||||
UpdateUser(ctx context.Context, in *UpdateUserRequest, opts ...grpc.CallOption) (*UpdateUserResponse, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type simpleBankClient struct {
|
|
||||||
cc grpc.ClientConnInterface
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewSimpleBankClient(cc grpc.ClientConnInterface) SimpleBankClient {
|
|
||||||
return &simpleBankClient{cc}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *simpleBankClient) CreateUser(ctx context.Context, in *CreateUserRequest, opts ...grpc.CallOption) (*CreateUserResponse, error) {
|
|
||||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
||||||
out := new(CreateUserResponse)
|
|
||||||
err := c.cc.Invoke(ctx, SimpleBank_CreateUser_FullMethodName, in, out, cOpts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *simpleBankClient) LoginUser(ctx context.Context, in *LoginUserRequest, opts ...grpc.CallOption) (*LoginUserResponse, error) {
|
|
||||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
||||||
out := new(LoginUserResponse)
|
|
||||||
err := c.cc.Invoke(ctx, SimpleBank_LoginUser_FullMethodName, in, out, cOpts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *simpleBankClient) VerifyEmail(ctx context.Context, in *VerifyEmailRequest, opts ...grpc.CallOption) (*VerifyEmailResponse, error) {
|
|
||||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
||||||
out := new(VerifyEmailResponse)
|
|
||||||
err := c.cc.Invoke(ctx, SimpleBank_VerifyEmail_FullMethodName, in, out, cOpts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *simpleBankClient) UpdateUser(ctx context.Context, in *UpdateUserRequest, opts ...grpc.CallOption) (*UpdateUserResponse, error) {
|
|
||||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
||||||
out := new(UpdateUserResponse)
|
|
||||||
err := c.cc.Invoke(ctx, SimpleBank_UpdateUser_FullMethodName, in, out, cOpts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SimpleBankServer is the server API for SimpleBank service.
|
|
||||||
// All implementations must embed UnimplementedSimpleBankServer
|
|
||||||
// for forward compatibility.
|
|
||||||
type SimpleBankServer interface {
|
|
||||||
CreateUser(context.Context, *CreateUserRequest) (*CreateUserResponse, error)
|
|
||||||
LoginUser(context.Context, *LoginUserRequest) (*LoginUserResponse, error)
|
|
||||||
VerifyEmail(context.Context, *VerifyEmailRequest) (*VerifyEmailResponse, error)
|
|
||||||
UpdateUser(context.Context, *UpdateUserRequest) (*UpdateUserResponse, error)
|
|
||||||
mustEmbedUnimplementedSimpleBankServer()
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnimplementedSimpleBankServer must be embedded to have
|
|
||||||
// forward compatible implementations.
|
|
||||||
//
|
|
||||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
|
||||||
// pointer dereference when methods are called.
|
|
||||||
type UnimplementedSimpleBankServer struct{}
|
|
||||||
|
|
||||||
func (UnimplementedSimpleBankServer) CreateUser(context.Context, *CreateUserRequest) (*CreateUserResponse, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method CreateUser not implemented")
|
|
||||||
}
|
|
||||||
func (UnimplementedSimpleBankServer) LoginUser(context.Context, *LoginUserRequest) (*LoginUserResponse, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method LoginUser not implemented")
|
|
||||||
}
|
|
||||||
func (UnimplementedSimpleBankServer) VerifyEmail(context.Context, *VerifyEmailRequest) (*VerifyEmailResponse, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method VerifyEmail not implemented")
|
|
||||||
}
|
|
||||||
func (UnimplementedSimpleBankServer) UpdateUser(context.Context, *UpdateUserRequest) (*UpdateUserResponse, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method UpdateUser not implemented")
|
|
||||||
}
|
|
||||||
func (UnimplementedSimpleBankServer) mustEmbedUnimplementedSimpleBankServer() {}
|
|
||||||
func (UnimplementedSimpleBankServer) testEmbeddedByValue() {}
|
|
||||||
|
|
||||||
// UnsafeSimpleBankServer may be embedded to opt out of forward compatibility for this service.
|
|
||||||
// Use of this interface is not recommended, as added methods to SimpleBankServer will
|
|
||||||
// result in compilation errors.
|
|
||||||
type UnsafeSimpleBankServer interface {
|
|
||||||
mustEmbedUnimplementedSimpleBankServer()
|
|
||||||
}
|
|
||||||
|
|
||||||
func RegisterSimpleBankServer(s grpc.ServiceRegistrar, srv SimpleBankServer) {
|
|
||||||
// If the following call pancis, it indicates UnimplementedSimpleBankServer was
|
|
||||||
// embedded by pointer and is nil. This will cause panics if an
|
|
||||||
// unimplemented method is ever invoked, so we test this at initialization
|
|
||||||
// time to prevent it from happening at runtime later due to I/O.
|
|
||||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
|
||||||
t.testEmbeddedByValue()
|
|
||||||
}
|
|
||||||
s.RegisterService(&SimpleBank_ServiceDesc, srv)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _SimpleBank_CreateUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(CreateUserRequest)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(SimpleBankServer).CreateUser(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: SimpleBank_CreateUser_FullMethodName,
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(SimpleBankServer).CreateUser(ctx, req.(*CreateUserRequest))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _SimpleBank_LoginUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(LoginUserRequest)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(SimpleBankServer).LoginUser(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: SimpleBank_LoginUser_FullMethodName,
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(SimpleBankServer).LoginUser(ctx, req.(*LoginUserRequest))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _SimpleBank_VerifyEmail_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(VerifyEmailRequest)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(SimpleBankServer).VerifyEmail(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: SimpleBank_VerifyEmail_FullMethodName,
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(SimpleBankServer).VerifyEmail(ctx, req.(*VerifyEmailRequest))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _SimpleBank_UpdateUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(UpdateUserRequest)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(SimpleBankServer).UpdateUser(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: SimpleBank_UpdateUser_FullMethodName,
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(SimpleBankServer).UpdateUser(ctx, req.(*UpdateUserRequest))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SimpleBank_ServiceDesc is the grpc.ServiceDesc for SimpleBank service.
|
|
||||||
// It's only intended for direct use with grpc.RegisterService,
|
|
||||||
// and not to be introspected or modified (even as a copy)
|
|
||||||
var SimpleBank_ServiceDesc = grpc.ServiceDesc{
|
|
||||||
ServiceName: "pb.SimpleBank",
|
|
||||||
HandlerType: (*SimpleBankServer)(nil),
|
|
||||||
Methods: []grpc.MethodDesc{
|
|
||||||
{
|
|
||||||
MethodName: "CreateUser",
|
|
||||||
Handler: _SimpleBank_CreateUser_Handler,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
MethodName: "LoginUser",
|
|
||||||
Handler: _SimpleBank_LoginUser_Handler,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
MethodName: "VerifyEmail",
|
|
||||||
Handler: _SimpleBank_VerifyEmail_Handler,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
MethodName: "UpdateUser",
|
|
||||||
Handler: _SimpleBank_UpdateUser_Handler,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Streams: []grpc.StreamDesc{},
|
|
||||||
Metadata: "service_simple_bank.proto",
|
|
||||||
}
|
|
||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.36.10
|
// protoc-gen-go v1.36.10
|
||||||
// protoc v6.33.1
|
// protoc v7.36.0
|
||||||
// source: user.proto
|
// source: user.proto
|
||||||
|
|
||||||
package pb
|
package pb
|
||||||
@@ -110,7 +110,7 @@ const file_user_proto_rawDesc = "" +
|
|||||||
"\x05email\x18\x03 \x01(\tR\x05email\x12J\n" +
|
"\x05email\x18\x03 \x01(\tR\x05email\x12J\n" +
|
||||||
"\x13password_changed_at\x18\x06 \x01(\v2\x1a.google.protobuf.TimestampR\x11passwordChangedAt\x129\n" +
|
"\x13password_changed_at\x18\x06 \x01(\v2\x1a.google.protobuf.TimestampR\x11passwordChangedAt\x129\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"created_at\x18\a \x01(\v2\x1a.google.protobuf.TimestampR\tcreatedAtB,Z*github.com/FernandoJVideira/simple_bank/pbb\x06proto3"
|
"created_at\x18\a \x01(\v2\x1a.google.protobuf.TimestampR\tcreatedAtB)Z'github.com/FernandoJVideira/api_tmpl/pbb\x06proto3"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
file_user_proto_rawDescOnce sync.Once
|
file_user_proto_rawDescOnce sync.Once
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ package pb;
|
|||||||
|
|
||||||
import "user.proto";
|
import "user.proto";
|
||||||
|
|
||||||
option go_package = "github.com/FernandoJVideira/simple_bank/pb";
|
option go_package = "github.com/FernandoJVideira/api_tmpl/pb";
|
||||||
|
|
||||||
message CreateUserRequest {
|
message CreateUserRequest {
|
||||||
string username = 1;
|
string username = 1;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ package pb;
|
|||||||
import "user.proto";
|
import "user.proto";
|
||||||
import "google/protobuf/timestamp.proto";
|
import "google/protobuf/timestamp.proto";
|
||||||
|
|
||||||
option go_package = "github.com/FernandoJVideira/simple_bank/pb";
|
option go_package = "github.com/FernandoJVideira/api_tmpl/pb";
|
||||||
|
|
||||||
message LoginUserRequest {
|
message LoginUserRequest {
|
||||||
string username = 1;
|
string username = 1;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ package pb;
|
|||||||
|
|
||||||
import "user.proto";
|
import "user.proto";
|
||||||
|
|
||||||
option go_package = "github.com/FernandoJVideira/simple_bank/pb";
|
option go_package = "github.com/FernandoJVideira/api_tmpl/pb";
|
||||||
|
|
||||||
message UpdateUserRequest {
|
message UpdateUserRequest {
|
||||||
string username = 1;
|
string username = 1;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ syntax = "proto3";
|
|||||||
|
|
||||||
package pb;
|
package pb;
|
||||||
|
|
||||||
option go_package = "github.com/FernandoJVideira/simple_bank/pb";
|
option go_package = "github.com/FernandoJVideira/api_tmpl/pb";
|
||||||
|
|
||||||
message VerifyEmailRequest {
|
message VerifyEmailRequest {
|
||||||
int64 id = 1;
|
int64 id = 1;
|
||||||
|
|||||||
@@ -9,28 +9,28 @@ import "rpc_update_user.proto";
|
|||||||
import "rpc_verify_email.proto";
|
import "rpc_verify_email.proto";
|
||||||
import "protoc-gen-openapiv2/options/annotations.proto";
|
import "protoc-gen-openapiv2/options/annotations.proto";
|
||||||
|
|
||||||
option go_package = "github.com/FernandoJVideira/simple_bank/pb";
|
option go_package = "github.com/FernandoJVideira/api_tmpl/pb";
|
||||||
|
|
||||||
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
|
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
|
||||||
info: {
|
info: {
|
||||||
title: "Simple Bank API"
|
title: "API Template"
|
||||||
version: "0.0.1"
|
version: "0.0.1"
|
||||||
contact: {
|
contact: {
|
||||||
name: "fvideira"
|
name: "fvideira"
|
||||||
url: "https://github.com/FernandoJVideira/simple_bank"
|
url: "https://github.com/FernandoJVideira/api_tmpl"
|
||||||
email: "03.pleaser-minster@icloud.com"
|
email: "support@example.com"
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
service SimpleBank {
|
service ApiTmpl {
|
||||||
rpc CreateUser (CreateUserRequest) returns (CreateUserResponse){
|
rpc CreateUser (CreateUserRequest) returns (CreateUserResponse){
|
||||||
option (google.api.http) = {
|
option (google.api.http) = {
|
||||||
post: "/v1/create_user"
|
post: "/v1/create_user"
|
||||||
body: "*"
|
body: "*"
|
||||||
};
|
};
|
||||||
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
|
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
|
||||||
description: "Create a new user in the Simple Bank system."
|
description: "Create a new user."
|
||||||
summary: "Create User"
|
summary: "Create User"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -40,7 +40,7 @@ service SimpleBank {
|
|||||||
body: "*"
|
body: "*"
|
||||||
};
|
};
|
||||||
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
|
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
|
||||||
description: "Login an existing user in the Simple Bank system."
|
description: "Login an existing user."
|
||||||
summary: "Login User"
|
summary: "Login User"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -49,7 +49,7 @@ service SimpleBank {
|
|||||||
get: "/v1/verify_email"
|
get: "/v1/verify_email"
|
||||||
};
|
};
|
||||||
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
|
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
|
||||||
description: "Verify user's email in the Simple Bank system."
|
description: "Verify a user's email."
|
||||||
summary: "Verify Email"
|
summary: "Verify Email"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,7 @@ service SimpleBank {
|
|||||||
body: "*"
|
body: "*"
|
||||||
};
|
};
|
||||||
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
|
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
|
||||||
description: "Update an existing user in the Simple Bank system."
|
description: "Update an existing user."
|
||||||
summary: "Update User"
|
summary: "Update User"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
+1
-1
@@ -4,7 +4,7 @@ package pb;
|
|||||||
|
|
||||||
import "google/protobuf/timestamp.proto";
|
import "google/protobuf/timestamp.proto";
|
||||||
|
|
||||||
option go_package = "github.com/FernandoJVideira/simple_bank/pb";
|
option go_package = "github.com/FernandoJVideira/api_tmpl/pb";
|
||||||
|
|
||||||
message User {
|
message User {
|
||||||
string username = 1;
|
string username = 1;
|
||||||
|
|||||||
@@ -4,5 +4,5 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
#* Start the server
|
#* Start the server
|
||||||
echo "Starting the s..."
|
echo "Starting the server..."
|
||||||
exec "$@"
|
exec "$@"
|
||||||
@@ -1 +0,0 @@
|
|||||||
exit status 1exit status 1exit status 1exit status 1
|
|
||||||
Reference in new issue
Block a user