good morning!!!!

Skip to content
Snippets Groups Projects
Verified Commit 11c01086 authored by a's avatar a
Browse files

change to RPC

parent 38d463c6
No related branches found
No related tags found
1 merge request!15Draft: V2
...@@ -11,6 +11,7 @@ import ( ...@@ -11,6 +11,7 @@ import (
"mime" "mime"
"net/http" "net/http"
"net/url" "net/url"
"strings"
"gfx.cafe/open/jrpc/pkg/codec" "gfx.cafe/open/jrpc/pkg/codec"
) )
...@@ -91,7 +92,7 @@ func (r *Codec) doReadGet() (msgs json.RawMessage, err error) { ...@@ -91,7 +92,7 @@ func (r *Codec) doReadGet() (msgs json.RawMessage, err error) {
return req.MarshalJSON() return req.MarshalJSON()
} }
func (r *Codec) doReadPut() (msgs json.RawMessage, err error) { func (r *Codec) doReadRPC() (msgs json.RawMessage, err error) {
method_up := r.r.URL.Query().Get("method") method_up := r.r.URL.Query().Get("method")
if method_up == "" { if method_up == "" {
method_up = r.r.URL.Path method_up = r.r.URL.Path
...@@ -148,11 +149,11 @@ func (c *Codec) doRead() { ...@@ -148,11 +149,11 @@ func (c *Codec) doRead() {
go func() { go func() {
var data json.RawMessage var data json.RawMessage
// TODO: implement eventsource // TODO: implement eventsource
switch c.r.Method { switch strings.ToUpper(c.r.Method) {
case http.MethodGet: case http.MethodGet:
data, err = c.doReadGet() data, err = c.doReadGet()
case http.MethodPut: case "RPC":
data, err = c.doReadPut() data, err = c.doReadRPC()
case http.MethodPost: case http.MethodPost:
data, err = io.ReadAll(c.r.Body) data, err = io.ReadAll(c.r.Body)
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment