Created
June 13, 2016 09:17
-
-
Save humorless/48dc720db139793e4e79eae4177965b9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"github.com/powerman/rpc-codec/jsonrpc2" | |
"net/http" | |
"net/rpc" | |
) | |
// Svc is an RPC service for testing. | |
type NqmEndpoint struct{} | |
type Res struct { | |
R int `json:"code"` | |
} | |
func (*NqmEndpoint) AddIcmp(vals []interface{}, res *Res) error { | |
v, _ := json.Marshal(vals) | |
fmt.Println(string(v)) | |
*res = Res{R: 0} | |
return nil | |
} | |
func main() { | |
_ = rpc.Register(&NqmEndpoint{}) | |
err := http.ListenAndServe("10.20.30.40:65534", jsonrpc2.HTTPHandler(nil)) | |
if err != nil { | |
fmt.Println(err.Error()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment