All routing files can be defined in the /routes directory, such as /routes/grpc.go. Then bind routes in the app/providers/grpc_service_provider.go file.
You can set the client interceptor in the app/grpc/kernel.go:UnaryClientInterceptorGroups method, the method can group interceptors. For example, interceptors.Client is included under the trace group.
the trace group can be applied to the configuration item grpc.clients.interceptors, in this way, the Client will be applied to all interceptors under the group. For example:
package config
import (
"github.com/goravel/framework/facades"
)
func init() {
config := facades.Config
config.Add("grpc", map[string]interface{}{
// Grpc Configuration
//
// Configure your server host
"host": config.Env("GRPC_HOST", ""),
// Configure your client host and interceptors.
// Interceptors can be the group name of UnaryClientInterceptorGroups in app/grpc/kernel.go.
"clients": map[string]any{
"user": map[string]any{
"host": config.Env("GRPC_USER_HOST", ""),
"port": config.Env("GRPC_USER_PORT", ""),
"interceptors": []string{"trace"},
},
},
})
}