pitaya icon indicating copy to clipboard operation
pitaya copied to clipboard

problems when i using pitaya-cli

Open lazycatNewton opened this issue 8 months ago • 0 comments

I want to test my logic by using pitaya-cli.

Pitaya REPL Client
>>> sethandshake {"user":{"aid":1}}
>>> connect localhost:9020
Using json client
connected!
>>> request logic.main.Ping {"id":1}
>>> sv->
PIT-400-proto: cannot parse invalid wire-format data
>>>
>>>

I am pretty sure the parameters I passed in are what I want. But pitaya reports to me like this.

I also tried the example in the pitaya-cli repo.

// Docs handler
func (h *MainHandler) Docs(ctx context.Context) (*protos.Doc, error) {
	d, err := pitaya.Documentation(true)
	if err != nil {
		return nil, fmt.Errorf("failed to generate documentation for pitaya routes: %w", err)
	}

	doc, err := json.Marshal(d)
	if err != nil {
		return nil, fmt.Errorf("failed to encode documentation JSON: %w", err)
	}

	return &protos.Doc{Doc: string(doc)}, nil
}

...

...

But it doesn't work

This is what I want to test handler code.

func (h *MainHandler) Ping(ctx context.Context, in *v1.TempMessage) (*v1.TempResponse, error) {
	fmt.Println(in.Id)
	rep := v1.TempResponse{
		Id: 1,
	}
	return &rep, nil
}

where I made a mistake? please

Or,Is there a more detailed example?

If anything I haven't expressed clearly, please let me know.

Thanks for your reply!

lazycatNewton avatar Jun 06 '24 11:06 lazycatNewton