Skip to content

How to use Chi with connect-go? #738

Answered by sudorandom
abitofhelp asked this question in Q&A
Discussion options

You must be logged in to vote

This is more a chi question. Chi's mux.Handle doesn't have the same behavior as net/http's mux.Handle. The net/http handler treats the first argument as a prefix. Chi treats the first argument as a pattern. Therefore, you can't use the result of NewGreeterServiceHandler as the arguments to chi's mux.Handle function. However, chi does have a separate method, mux.Mount (https://pkg.go.dev/github.com/go-chi/chi/v5#Mux.Mount) that has a similar behavior to net/http's mux.Handle.

mux.Mount(helloworldv1connect.NewGreeterServiceHandler(&GreeterServer{}))

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@abitofhelp
Comment options

Answer selected by abitofhelp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants