-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* init * WIP config * WIP add proxy server * fmt * WIP * setup proxy server * clean go.mod * lint * lint * lint * custom codec * lint * add comments * change grpc-proxy port * add grpc-web * update server/start.go * add tests * add test with client * Update server/start.go Co-authored-by: Anil Kumar Kammari <anil@vitwit.com> * Update server/start.go Co-authored-by: Amaury <amaury.martiny@protonmail.com> * Update server/start.go Co-authored-by: Amaury <amaury.martiny@protonmail.com> * review changes * review changes * Update server/start.go Co-authored-by: Anil Kumar Kammari <anil@vitwit.com> Co-authored-by: Amaury <amaury.martiny@protonmail.com> Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
01eec66
commit b771eff
Showing
9 changed files
with
438 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package grpc | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/cosmos/cosmos-sdk/server/config" | ||
"github.com/improbable-eng/grpc-web/go/grpcweb" | ||
"google.golang.org/grpc" | ||
) | ||
|
||
// StartGRPCWeb starts a gRPC-Web server on the given address. | ||
func StartGRPCWeb(grpcSrv *grpc.Server, config config.Config) (*http.Server, error) { | ||
wrappedServer := grpcweb.WrapServer(grpcSrv) | ||
handler := func(resp http.ResponseWriter, req *http.Request) { | ||
wrappedServer.ServeHTTP(resp, req) | ||
} | ||
grpcWebSrv := &http.Server{ | ||
Addr: config.GRPCWeb.Address, | ||
Handler: http.HandlerFunc(handler), | ||
} | ||
if err := grpcWebSrv.ListenAndServe(); err != nil { | ||
return nil, err | ||
} | ||
return grpcWebSrv, nil | ||
} |
Oops, something went wrong.