Set custom handler in gRPC

392 Views Asked by At

I want to use a custom Handler( Specifically want to use a chi router) in gRPC. I have tried to search on the internet but don’t found help to set a custom handler in the gRPC server.

Below is the code for my chi handler and I want to set it in gRPC server.

func (app *Config) routes() http.Handler {
    mux := chi.NewRouter()

    // specify who is allowed to connect
    mux.Use(cors.Handler(cors.Options{
        AllowedOrigins:   []string{"https://*", "http://*"},
        AllowedMethods:   []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
        AllowedHeaders:   []string{"Accept", "Authorization", "Content-Type", "X-CSRF-Token"},
        ExposedHeaders:   []string{"Link"},
        AllowCredentials: true,
        MaxAge:           300,
    }))
    mux.Use(middleware.Heartbeat("/ping"))

    mux.Get("/", app.RequestCome)
    mux.Post("/authenticate", app.Authenticate)
    return mux
}

Thanks

0

There are 0 best solutions below