examples: Update and fix outdated (#420)
Update examples/server/rate-limiting to use the same replace directive strategy as the auth-middleware example, and fix the breakages. Also remove the unneeded type parameters in examples/client/middleware.
This commit is contained in:
parent
9d34aff732
commit
b774809086
1 changed files with 32 additions and 25 deletions
|
|
@ -17,10 +17,10 @@ var nextProgressToken atomic.Int64
|
|||
// from the client.
|
||||
func main() {
|
||||
c := mcp.NewClient(&mcp.Implementation{Name: "test"}, nil)
|
||||
c.AddSendingMiddleware(addProgressToken[*mcp.ClientSession])
|
||||
c.AddSendingMiddleware(addProgressToken)
|
||||
}
|
||||
|
||||
func addProgressToken[S mcp.Session](h mcp.MethodHandler) mcp.MethodHandler {
|
||||
func addProgressToken(h mcp.MethodHandler) mcp.MethodHandler {
|
||||
return func(ctx context.Context, method string, req mcp.Request) (result mcp.Result, err error) {
|
||||
if rp, ok := req.GetParams().(mcp.RequestParams); ok {
|
||||
rp.SetProgressToken(nextProgressToken.Add(1))
|
||||
|
|
|
|||
Loading…
Reference in a new issue