grpcurlreq

package module
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 8 Imported by: 2

README

grpcurlreq

grpcurlreq is parser for gRPCurl command.

Usage

package main

import (
	"encoding/json"
	"fmt"
	"log"

	"github.com/k1LoW/grpcurlreq"
)

func main() {
	cmd := `grpcurl -d '{"id": 1234, "tags": ["foo","bar"]}' grpc.server.com:443 my.custom.server.Service/Method`
	p, err := grpcurlreq.Parse(cmd)
	if err != nil {
		log.Fatal(err)
	}
	b, err := json.Marshal(p)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(string(b))

	// Output:
	// {"addr":"grpc.server.com:443","method":"my.custom.server.Service/Method","messages":[{"id":1234,"tags":["foo","bar"]}]}
}

Documentation

Overview

Example
package main

import (
	"encoding/json"
	"fmt"
	"log"

	"github.com/k1LoW/grpcurlreq"
)

func main() {
	cmd := `grpcurl -d '{"id": 1234, "tags": ["foo","bar"]}' grpc.server.com:443 my.custom.server.Service/Method`
	p, err := grpcurlreq.Parse(cmd)
	if err != nil {
		log.Fatal(err)
	}
	b, err := json.Marshal(p)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(string(b))

}
Output:

{"addr":"grpc.server.com:443","method":"my.custom.server.Service/Method","messages":[{"id":1234,"tags":["foo","bar"]}]}

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Parsed

type Parsed struct {
	SubCmd   string                   `json:"cmd,omitempty"`
	Addr     string                   `json:"addr,omitempty"`
	Headers  metadata.MD              `json:"headers,omitempty"`
	Method   string                   `json:"method,omitempty"`
	Messages []map[string]interface{} `json:"messages,omitempty"`
}

func Parse

func Parse(cmd ...string) (*Parsed, error)

Parse a grpcurl command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL