GithubHelp home page GithubHelp logo

rookie-ninja / rk-boot Goto Github PK

View Code? Open in Web Editor NEW
494.0 6.0 56.0 7.29 MB

Build microservice with rk-boot and let the team take over clean and tidy code.

Home Page: https://rkdev.info

License: Apache License 2.0

Go 90.82% Makefile 9.18%
go golang grpc gin middleware echo echo-middleware gin-middleware go-project-structure gorilla-mux

rk-boot's People

Contributors

baimamboukar avatar dongxuny avatar fossabot avatar kevwan avatar mrigesh-dq avatar naruepanart avatar shengyu avatar zhengguo07q avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

rk-boot's Issues

http://localhost:8080/sw/ render failed

Describe the bug

To Reproduce
MacBook Pro

# go.mod

module swagger_rk

go 1.20

require (
	github.com/gin-gonic/gin v1.9.1
	github.com/rookie-ninja/rk-boot/v2 v2.2.20
	github.com/rookie-ninja/rk-gin/v2 v2.2.21
)

require (
	github.com/benbjohnson/clock v1.3.0 // indirect
	github.com/beorn7/perks v1.0.1 // indirect
	github.com/bytedance/sonic v1.9.1 // indirect
	github.com/cenkalti/backoff/v4 v4.2.1 // indirect
	github.com/cespare/xxhash/v2 v2.2.0 // indirect
	github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
	github.com/fsnotify/fsnotify v1.6.0 // indirect
	github.com/gabriel-vasile/mimetype v1.4.2 // indirect
	github.com/gin-contrib/pprof v1.4.0 // indirect
	github.com/gin-contrib/sse v0.1.0 // indirect
	github.com/go-logr/logr v1.2.4 // indirect
	github.com/go-logr/stdr v1.2.2 // indirect
	github.com/go-playground/locales v0.14.1 // indirect
	github.com/go-playground/universal-translator v0.18.1 // indirect
	github.com/go-playground/validator/v10 v10.14.0 // indirect
	github.com/goccy/go-json v0.10.2 // indirect
	github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
	github.com/golang/protobuf v1.5.3 // indirect
	github.com/google/uuid v1.3.1 // indirect
	github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect
	github.com/hashicorp/hcl v1.0.0 // indirect
	github.com/json-iterator/go v1.1.12 // indirect
	github.com/klauspost/cpuid/v2 v2.2.4 // indirect
	github.com/leodido/go-urn v1.2.4 // indirect
	github.com/magiconair/properties v1.8.7 // indirect
	github.com/mattn/go-isatty v0.0.19 // indirect
	github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
	github.com/mitchellh/mapstructure v1.5.0 // indirect
	github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
	github.com/modern-go/reflect2 v1.0.2 // indirect
	github.com/openzipkin/zipkin-go v0.4.2 // indirect
	github.com/pelletier/go-toml/v2 v2.0.8 // indirect
	github.com/prometheus/client_golang v1.16.0 // indirect
	github.com/prometheus/client_model v0.4.0 // indirect
	github.com/prometheus/common v0.44.0 // indirect
	github.com/prometheus/procfs v0.10.1 // indirect
	github.com/rookie-ninja/rk-entry/v2 v2.2.19 // indirect
	github.com/rookie-ninja/rk-logger v1.2.13 // indirect
	github.com/rookie-ninja/rk-query v1.2.14 // indirect
	github.com/rs/xid v1.3.0 // indirect
	github.com/spf13/afero v1.9.5 // indirect
	github.com/spf13/cast v1.5.1 // indirect
	github.com/spf13/jwalterweatherman v1.1.0 // indirect
	github.com/spf13/pflag v1.0.5 // indirect
	github.com/spf13/viper v1.16.0 // indirect
	github.com/subosito/gotenv v1.4.2 // indirect
	github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
	github.com/ugorji/go/codec v1.2.11 // indirect
	go.opentelemetry.io/contrib v1.19.0 // indirect
	go.opentelemetry.io/otel v1.18.0 // indirect
	go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.18.0 // indirect
	go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.18.0 // indirect
	go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.18.0 // indirect
	go.opentelemetry.io/otel/exporters/zipkin v1.18.0 // indirect
	go.opentelemetry.io/otel/metric v1.18.0 // indirect
	go.opentelemetry.io/otel/sdk v1.18.0 // indirect
	go.opentelemetry.io/otel/trace v1.18.0 // indirect
	go.opentelemetry.io/proto/otlp v1.0.0 // indirect
	go.uber.org/atomic v1.11.0 // indirect
	go.uber.org/multierr v1.10.0 // indirect
	go.uber.org/ratelimit v0.3.0 // indirect
	go.uber.org/zap v1.25.0 // indirect
	golang.org/x/arch v0.3.0 // indirect
	golang.org/x/crypto v0.11.0 // indirect
	golang.org/x/net v0.12.0 // indirect
	golang.org/x/sys v0.12.0 // indirect
	golang.org/x/text v0.11.0 // indirect
	google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 // indirect
	google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect
	google.golang.org/grpc v1.58.0 // indirect
	google.golang.org/protobuf v1.31.0 // indirect
	gopkg.in/ini.v1 v1.67.0 // indirect
	gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
	gopkg.in/yaml.v2 v2.4.0 // indirect
	gopkg.in/yaml.v3 v3.0.1 // indirect
)

# boot.yaml

---
gin:
  - name: greeter                                          # Required
    port: 8080                                             # Required
    enabled: true                                          # Required
    sw:
      enabled: true                                        # Optional, default: false
# main.go
// Copyright (c) 2021 rookie-ninja
//
// Use of this source code is governed by an Apache-style
// license that can be found in the LICENSE file.

package main

import (
	"context"
	"fmt"
	"net/http"

	"github.com/gin-gonic/gin"
	rkboot "github.com/rookie-ninja/rk-boot/v2"
	rkgin "github.com/rookie-ninja/rk-gin/v2/boot"
)

// @title Swagger Example API
// @version 1.0
// @description This is a sample rk-demo server.
// @termsOfService http://swagger.io/terms/

// @securityDefinitions.basic BasicAuth

// @contact.name API Support
// @contact.url http://www.swagger.io/support
// @contact.email [email protected]

// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
func main() {
	// Create a new boot instance.
	boot := rkboot.NewBoot()

	// Register handler
	entry := rkgin.GetGinEntry("greeter")
	entry.Router.GET("/v1/greeter", Greeter)

	// Bootstrap
	boot.Bootstrap(context.TODO())

	boot.WaitForShutdownSig(context.TODO())
}

// Greeter handler
// @Summary Greeter
// @Id 1
// @Tags Hello
// @version 1.0
// @Param name query string true "name"
// @produce application/json
// @Success 200 {object} GreeterResponse
// @Router /v1/greeter [get]
func Greeter(ctx *gin.Context) {
	ctx.JSON(http.StatusOK, &GreeterResponse{
		Message: fmt.Sprintf("Hello %s!", ctx.Query("name")),
	})
}

type GreeterResponse struct {
	Message string
}

Expected behavior

$ curl -X GET localhost:8080/rk/v1/ready
{
"ready": true
}

$ curl -X GET localhost:8080/rk/v1/alive
{
"alive": true
}

Screenshots
image

Desktop (please complete the following information):

  • OS: macOS Ventura 13.3.1 (a)
  • Browser chrome version 118.0.5993.117 (Official Build) (x86_64)

NewBoot should find boot.yaml in default project dir when called via Go Unit Test

When rkBoot setup is required to run a unit test in go, the NewBoot() function should find boot.yaml by default.
Providing a different Path for every Test depending on the Test location is sub-optimal.
Also, when the boot.yaml has entries which are relative to boot.yaml, they should be also be found in a Unit Test without extra path requirements.

Describe the solution you'd like
NewBoot() function should find boot,yaml by default in the project dir .

Describe alternatives you've considered
I have used TestMain to call one Setup() function which starts rkBoot, but this must also look for the path to boot,yaml relative to the Setup function location (which cannot exist in main package as it causes cricular dependancies)

Additional context
Add any other context or screenshots about the feature request here.

https://stackoverflow.com/questions/23729790/how-can-i-do-test-setup-using-the-testing-package-in-go

Config entry override from env

Describe the bug
Config values in a ConfigEntry file cannot be overridden from env vars

To Reproduce

  1. Create config entry in boot.yaml:
  - name: db-config
    locale: "*::*::*::*"
    path: config/db.yaml
  1. Add name value pair in db.yaml config: host: localhost
  2. Override from env os.Setenv("host=anotherhost")

Expected behavior
rkentry.GlobalAppCtx.GetConfigEntry("db-config").GetViper().GetString("host") should be equal "anotherhost"

Swagger/Docs Panic: no / before catch-all in path '\/sw\*any'

Describe the bug
Swagger / Docs enabled in boot.yaml produces panic in rk-boot - Bootstrap
go/pkg/mod/github.com/rookie-ninja/rk-boot/[email protected]/boot.go:174
panic: no / before catch-all in path '/\sw*any'

To Reproduce
Steps to reproduce the behavior:

swag init -g api/main.go
go run .\api\main.go
see go.mod below...

Desktop (please complete the following information):

  • OS: Windows 10
  • VSCode Terminal > go run .\api\main.go
  • Version rk-boot/[email protected]

func main() {
boot := rkboot.NewBoot()
...
boot.Bootstrap(context.TODO())
boot.WaitForShutdownSig(context.TODO())
}

boot,yaml includes (extract):
gin:

  • name: app-api
    port: 8088
    enabled: true
    loggerEntry: zap-log
    eventEntry: event-log
    commonService:
    enabled: true # health endpoints
    pathPrefix: "/restricted/common"
    sw:
    enabled: true # Swagger UI
    path: "/sw"
    docs:
    enabled: true # API Doc
    path: "/docs"
    prom:
    enabled: true # Prometheus Client
    path: "/public/metrics"
    middleware:
    logging:
    enabled: true
    loggerEncoding: "json"
    loggerOutputPaths: ["stdout"]
    eventEncoding: "json"
    eventOutputPaths: ["stdout"]
    prom:
    enabled: true
    meta:
    enabled: true
    trace:
    enabled: true

Additional context
{"level":"ERROR","ts":"2022-11-23T09:56:32.916+0100","caller":"[email protected]/boot.go:257","msg":"Panic occured, shutting down... \ngoroutine 1 [running]:\nruntime/debug.Stack()\n\tC:/Program Files/Go/src/runtime/debug/stack.go:24 +0x65\ngithub.com/rookie-ninja/rk-boot/v2.syncLog({0xc000620000, 0x24})\n\tC:/Users//go/pkg/mod/github.com/rookie-ninja/rk-boot/[email protected]/boot.go:249 +0x65\npanic({0x12034a0, 0xc000339280})\n\tC:/Program Files/Go/src/runtime/panic.go:838 +0x207\ngithub.com/gin-gonic/gin.(*node).insertChild(0x12e2840?, {0xc00039b532?, 0x0?}, {0xc00039b530, 0x9}, {0xc00020d1d0, 0x6, 0x6})\n\tC:/Users/mcconig/go/pkg/mod/github.com/gin-gonic/[email protected]/tree.go:363 +0xb2e\ngithub.com/gin-gonic/gin.(*node).addRoute(0x1374618?, {0xc00039b530, 0x9}, {0xc00020d1d0, 0x6, 0x6})\n\tC:/Users//go/pkg/mod/github.com/gin-gonic/[email protected]/tree.go:252 +0xa39\ngithub.com/gin-gonic/gin.(*Engine).addRoute(0xc00008cea0, {0x1374618, 0x3}, {0xc00039b530, 0x9}, {0xc00020d1d0, 0x6, 0x6})\n\tC:/Users//go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:331
+0x226\ngithub.com/gin-gonic/gin.(*RouterGroup).handle(0xc00008cea0, {0x1374618, 0x3}, {0xc00039b4f0?, 0xc00020cb10?}, {0xc0000068f0, 0x1, 0x68?})\n\tC:/Users/
/go/pkg/mod/github.com/gin-gonic/[email protected]/routergroup.go:88 +0x145\ngithub.com/gin-gonic/gin.(*RouterGroup).GET(...)\n\tC:/Users//go/pkg/mod/github.com/gin-gonic/[email protected]/routergroup.go:116\ngithub.com/rookie-ninja/rk-gin/v2/boot.(*GinEntry).Bootstrap(0xc00062adc0, {0x1685d40, 0xc00020cb10})\n\tC:/Users/mcconig/go/pkg/mod/github.com/rookie-ninja/rk-gin/[email protected]/boot/gin_entry.go:387 +0x53f\ngithub.com/rookie-ninja/rk-boot/v2.(*Boot).Bootstrap(0xc0001aed20, {0x1685cd0, 0xc000036068})\n\tC:/Users/mcconig/go/pkg/mod/github.com/rookie-ninja/rk-boot/[email protected]/boot.go:174 +0x46e\nmain.main()\n\tC:/Users//repos/configcontrol-api-ssh/api/main.go:28 +0x575\n","eventId":"d1e0a1e6-3095-408a-9e1c-a19a2edfdb3c","RootCause":"no / before catch-all in path '/\sw\*any'"}
panic: no / before catch-all in path '/\sw*any' [recovered]
panic: no / before catch-all in path '/\sw*any'

go.mod:

go 1.18

require (
github.com/gin-gonic/gin v1.8.1
github.com/rookie-ninja/rk-boot/v2 v2.2.11
github.com/rookie-ninja/rk-db/mysql v1.2.12
github.com/rookie-ninja/rk-entry/v2 v2.2.11
github.com/rookie-ninja/rk-gin/v2 v2.2.14
github.com/swaggo/swag v1.8.7
gorm.io/gorm v1.24.1
)

require (
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/gin-contrib/pprof v1.3.0 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.6 // indirect
github.com/go-openapi/spec v0.20.4 // indirect
github.com/go-openapi/swag v0.19.15 // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/go-playground/validator/v10 v10.10.0 // indirect
github.com/go-sql-driver/mysql v1.6.0 // indirect
github.com/goccy/go-json v0.9.7 // indirect
github.com/golang-jwt/jwt/v4 v4.4.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/openzipkin/zipkin-go v0.4.0 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.1 // indirect
github.com/prometheus/client_golang v1.13.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/rookie-ninja/rk-logger v1.2.12 // indirect
github.com/rookie-ninja/rk-query v1.2.14 // indirect
github.com/rs/xid v1.3.0 // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.12.0 // indirect
github.com/subosito/gotenv v1.3.0 // indirect
github.com/ugorji/go/codec v1.2.7 // indirect
go.opentelemetry.io/contrib v1.8.0 // indirect
go.opentelemetry.io/otel v1.10.0 // indirect
go.opentelemetry.io/otel/exporters/jaeger v1.8.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.10.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.10.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.10.0 // indirect
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.8.0 // indirect
go.opentelemetry.io/otel/exporters/zipkin v1.10.0 // indirect
go.opentelemetry.io/otel/sdk v1.10.0 // indirect

how can I find the jwt endpoints?

Describe the bug
A clear and concise description of what the bug is.
Hi,

First of all, really nice work done here.

After setting up jwt middleware I am unable to acess sw even when ignore is set to /sw, how can I know jwt endpoints to get access token?

To Reproduce
Steps to reproduce the behavior:

gin:
  - name: greeter                                          # Required
    port: 8080                                             # Required
    enabled: true                                          # Required
    commonService:
      enabled: true                                        # Optional, default: false
    sw:
      enabled: true                                        # Optional, default: false
    docs:
      enabled: true                                        # Optional, default: false
    middleware:
     jwt:
       enabled: true                                     # Optional, default: false
       ignorePrefix:                                      # Optional, default: []
         - "/sw"

Expected behavior
after ignoring /sw I should be able to access sw and retrieve endpoints to get jwt token

Desktop (please complete the following information):

  • OS: Linux
  • Brave
  • Version

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version v2.2.3

New API error format requested

A new error template is needed which may match bellow reqquirments.

1: Provide multiple API error format to select by user in boot.yaml
2: Extendable by user
3: Custom error format should be injectable

Cannot override boot config values using environment variables

Description
Cannot override boot config values for JWT Middleware from environment variables.

Steps to reproduce the behavior:

  1. Create boot.yaml file
echo:
    - name: greeter
      port: 8080
      enabled: true
      middleware:
          jwt:
              enabled: false
              asymmetric:
                  algorithm: ""
                  publicKey: ""
                  privateKey: ""
  1. create a main.go file as per below and update environment variables for JWT token
package main

import (
	"context"
	"fmt"
	"github.com/labstack/echo/v4"
	rkboot "github.com/rookie-ninja/rk-boot/v2"
	rkecho "github.com/rookie-ninja/rk-echo/boot"
	"github.com/rookie-ninja/rk-echo/middleware/context"
	"net/http"
	"os"
)

func main() {
       // ideally this will be added by CI/CD pipeline I have added this as an example
	_ = os.Setenv("RK_ECHO_0_MIDDLEWARE_JWT_ENABLED", "true")
	_ = os.Setenv("RK_ECHO_0_MIDDLEWARE_JWT_ASYMMETRIC_ALGORITHM", "ES256")
	_ = os.Setenv("RK_ECHO_0_MIDDLEWARE_JWT_ASYMMETRIC_PUBLICKEY", "xxxxx")
	_ = os.Setenv("RK_ECHO_0_MIDDLEWARE_JWT_ASYMMETRIC_PRIVATEKEY", "xxxxx")

	// Create a new boot instance.
	boot := rkboot.NewBoot()

	// Register handler
	echoEntry := rkecho.GetEchoEntry("greeter")
	echoEntry.Echo.GET("/v1/greeter", Greeter)

	// Bootstrap
	boot.Bootstrap(context.TODO())

	boot.WaitForShutdownSig(context.TODO())
}

func Greeter(ctx echo.Context) error {
	// Get JWT token
	rkechoctx.GetJwtToken(ctx)

	return ctx.JSON(http.StatusOK, &GreeterResponse{
		Message: fmt.Sprintf("Hello %s!", ctx.QueryParam("name")),
	})
}

type GreeterResponse struct {
	Message string
}
  1. Run program
go run main.go
test git:(HB-13764---Initial-VMS-Service-and-Auth) ✗ go run main.go
2022-09-21T12:09:50.429+1000	INFO	entry/util.go:299	Found ENV to override, applying...	{"env": ["RK_ECHO_0_MIDDLEWARE_JWT_ENABLED=true => echo[0].middleware.jwt.enabled=true", "RK_ECHO_0_MIDDLEWARE_JWT_ASYMMETRIC_ALGORITHM=ES256 => echo[0].middleware.jwt.asymmetric.algorithm=ES256", "RK_ECHO_0_MIDDLEWARE_JWT_ASYMMETRIC_PUBLICKEY=xxxxx => echo[0].middleware.jwt.asymmetric.publickey=xxxxx", "RK_ECHO_0_MIDDLEWARE_JWT_ASYMMETRIC_PRIVATEKEY=xxxxx => echo[0].middleware.jwt.asymmetric.privatekey=xxxxx"]}
2022-09-21T12:09:50.430+1000	INFO	boot/echo_entry.go:682	Bootstrap EchoEntry	{"eventId": "28f73547-7079-4fa1-a6e5-9483e761b44b", "entryName": "greeter", "entryType": "EchoEntry"}
------------------------------------------------------------------------
endTime=2022-09-21T12:09:50.430602+10:00
startTime=2022-09-21T12:09:50.430542+10:00
elapsedNano=59241
timezone=AEST
ids={"eventId":"28f73547-7079-4fa1-a6e5-9483e761b44b"}
app={"appName":"rk","appVersion":"local","entryName":"greeter","entryType":"EchoEntry"}
env={"arch":"amd64","domain":"*","hostname":"C02YX1MSLVCF","localIP":"10.131.145.133","os":"darwin"}
payloads={"echoPort":8080}
counters={}
pairs={}
timing={}
remoteAddr=localhost
operation=Bootstrap
resCode=OK
eventStatus=Ended
EOE
  1. Make a request with Authorization in header, the request should have failed as the certs provided is not valid.
➜  auth git:(HB-13764---Initial-VMS-Service-and-Auth) ✗ curl -XGET -H 'Authorization: eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkIjo0NzA2MSwidmFsaWRhdGVkIjp0cnVlfSwiY29tbW9uIjp7ImNsaWVudCI6MTQsImJ1aWxkaW5nIjoxNTIsInRlbmFudCI6ODIyfSwic2NvcGVzIjpbInVzZXIuYXBwLmFsbCJdLCJpc3MiOiJsb2NhbGhvc3QiLCJleHAiOjIyNjQ4NTUxNDF9.ywC-EiD-GCWPM3cEor5i0Jcmwb3-ASf8sUjJ2SdQy55MCr8s8fFO1Xm3itWLFQczU2toEdUZv96VcteU0eTBHA' 'http://localhost:8080/v1/greeter'
{"Message":"Hello !"}

Expected behavior
The above request should not validate passed to the handler as I have use the env to overide the boot variables.

Additional context
The reason we require this is because when deploying our micro-services using CI/CD pipeline the configurations will get injected during build as environment variables.

grpc的sw中的自定义headers没有效果

hello,
Describe the bug

  1. 在boot.yaml 中启用 grpc,
  2. middleware中启用auth、apiKey,为token-1,
  3. 开启 sw,配置headers: [ "X-API-Key:token-1" ],想要得到每次在swagger web 上发请求时,能带上头部X-API-Key:token-1
  4. 但是现在,在 sw 上 发请求 ,得到的都是 401 ,未认证。
  5. 如:
curl -X 'GET' \
  'https://localhost:8082/api/v1/greeter?name=1' \
  -H 'accept: application/json'

{
  "error": {
    "code": 401,
    "status": "Unauthorized",
    "message": "missing authorization, provide one of bellow auth header:[X-API-Key]",
    "details": [
      {
        "code": 16,
        "status": "Unauthenticated",
        "message": "[from-grpc] missing authorization, provide one of bellow auth header:[X-API-Key]"
      }
    ]
  }
}

rk-boot/v2 v2.1.2
rk-grpc/v2 v2.0.2
rk-entry/v2 v2.1.7

谢谢。

Support fiber and question

I like fiber https://github.com/gofiber/fiber , It is fast and simple than gin or echo
Will you support fiber in rk-boot ?
If your not I want try do it
I have two question

  1. I found few unuse dependencies in rk-boot . for example, I only use gin build a slight and simple micro-service , rk-boot add echo package . I dont need it , How do you solve it ? I want my application slight
  2. How do I contribute code if I develop such as rk-fiber ? What I should follow rules

一个进程启动grpc和gin时的swagger页面访问问题

Describe the bug
你好,
计划,一个boot.yaml,启动两个服务:grpc 和 gin,不同的 entryName
现在能启动,能通过不同的端口访问到 grpc 和 gin 的服务
但是,访问 sw 时,
只能 grpc 的 sw 正常,gin 的 sw 会提示:Failed to load API definition.
在控制台还会看到日志:2022/05/18 18:19:05 http: TLS handshake error from [::1]:12819: remote error: tls: unknown certificate

不过,访问 自定义的和common service 的路由 都是能正常访问的。
配置如下:

  1. boot.yaml
grpc:
  - name: grpc-api                                          # Required
    description: "grpc api"                         # Optional, default: ""
    enabled: true                                          # Required
    port: 58085                                             # Required
    sw:
      enabled: true                                        # Optional, default: false
gin:
  - name: rest-api
    port: 59095                    # 监听端口
    enabled: true                 # 开启 gin 微服务
    sw:
      enabled: true               # 开启 Swagger UI,默认路径为 /sw
  1. main.go
boot := rkboot.NewBoot()
ginEntry := rkgin.GetGinEntry("rest-api")
ginEntry.Router.GET("/api/v1/aa", restAPIHandler.GetAA)

// Get grpc entry with name
grpcEntry := rkgrpc.GetGrpcEntry("grpc-api")
boot.Bootstrap(context.Background())

Additional context
rk-boot/v2 v2.1.2
rk-entry/v2 v2.1.7
rk-gin/v2 v2.1.2
rk-grpc/v2 v2.1.6

谢谢。

connect mongodb cluster error, can you provide a case? Thank you.

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

HTTP Access logs

  1. Support for HTTP access logs.
  2. Support for reverse proxies in front of rk-boot for the features the web server supports (such as access logs)

Support more RPC framework

Is your feature request related to a problem? Please describe.
Currently, rk-boot support gRPC and Gin RPC framework. More needs to be supported.

Describe the solution you'd like
Support bellow popular frameworks.

  • Beego (Ali)
  • Echo
  • Go kit
  • Fast http
  • Mux
  • HttpRouter
  • TarsGo (Tencent)
  • brpc (Baidu)

Support Cloud Entry

Is your feature request related to a problem? Please describe.
Cloud provider entry may be useful for rk-boot.

Describe the solution you'd like

  • AWS
  • Azure
  • Google cloud
  • Ali Cloud
  • Tencent Cloud
  • Huawei Cloud

Unable to use Postgres DB in gRPC gateway endpoint

There doesn't appear to be any way to use a database driver in gRPC endpoints. You have to register endpoints prior to bootstrapping the program, but you cannot access the DB instance until after bootstrapping the program, meaning the DB instance is inaccessible until after setting up gRPC endpoints.
If there is a way I missed, or some kind of workaround, please let me know. Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.