10
									
								
								handler.go
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								handler.go
									
									
									
									
									
								
							| @@ -28,19 +28,19 @@ var ( | |||||||
| ) | ) | ||||||
|  |  | ||||||
| type patHandler struct { | type patHandler struct { | ||||||
| 	pat   rutil.Pattern |  | ||||||
| 	mtype *methodType | 	mtype *methodType | ||||||
| 	name  string |  | ||||||
| 	rcvr  reflect.Value | 	rcvr  reflect.Value | ||||||
|  | 	name  string | ||||||
|  | 	pat   rutil.Pattern | ||||||
| } | } | ||||||
|  |  | ||||||
| type httpHandler struct { | type httpHandler struct { | ||||||
| 	name     string |  | ||||||
| 	opts     server.HandlerOptions | 	opts     server.HandlerOptions | ||||||
| 	sopts    server.Options |  | ||||||
| 	eps      []*register.Endpoint |  | ||||||
| 	hd       interface{} | 	hd       interface{} | ||||||
| 	handlers map[string][]patHandler | 	handlers map[string][]patHandler | ||||||
|  | 	name     string | ||||||
|  | 	eps      []*register.Endpoint | ||||||
|  | 	sopts    server.Options | ||||||
| 	sync.RWMutex | 	sync.RWMutex | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										14
									
								
								http.go
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								http.go
									
									
									
									
									
								
							| @@ -24,20 +24,18 @@ import ( | |||||||
| ) | ) | ||||||
|  |  | ||||||
| type httpServer struct { | type httpServer struct { | ||||||
| 	sync.RWMutex |  | ||||||
| 	opts        server.Options |  | ||||||
| 	handlers    map[string]server.Handler |  | ||||||
| 	hd                  server.Handler | 	hd                  server.Handler | ||||||
|  | 	rsvc                *register.Service | ||||||
|  | 	handlers            map[string]server.Handler | ||||||
| 	exit                chan chan error | 	exit                chan chan error | ||||||
| 	subscribers         map[*httpSubscriber][]broker.Subscriber | 	subscribers         map[*httpSubscriber][]broker.Subscriber | ||||||
| 	// used for first registration |  | ||||||
| 	registered bool |  | ||||||
| 	// register service instance |  | ||||||
| 	rsvc                *register.Service |  | ||||||
| 	init                bool |  | ||||||
| 	errorHandler        func(context.Context, server.Handler, http.ResponseWriter, *http.Request, error, int) | 	errorHandler        func(context.Context, server.Handler, http.ResponseWriter, *http.Request, error, int) | ||||||
| 	pathHandlers        map[*regexp.Regexp]http.HandlerFunc | 	pathHandlers        map[*regexp.Regexp]http.HandlerFunc | ||||||
| 	contentTypeHandlers map[string]http.HandlerFunc | 	contentTypeHandlers map[string]http.HandlerFunc | ||||||
|  | 	opts                server.Options | ||||||
|  | 	sync.RWMutex | ||||||
|  | 	registered bool | ||||||
|  | 	init       bool | ||||||
| } | } | ||||||
|  |  | ||||||
| func (h *httpServer) newCodec(ct string) (codec.Codec, error) { | func (h *httpServer) newCodec(ct string) (codec.Codec, error) { | ||||||
|   | |||||||
| @@ -6,12 +6,12 @@ import ( | |||||||
| ) | ) | ||||||
|  |  | ||||||
| type httpMessage struct { | type httpMessage struct { | ||||||
| 	topic       string |  | ||||||
| 	payload     interface{} | 	payload     interface{} | ||||||
| 	contentType string |  | ||||||
| 	header      metadata.Metadata |  | ||||||
| 	body        []byte |  | ||||||
| 	codec       codec.Codec | 	codec       codec.Codec | ||||||
|  | 	header      metadata.Metadata | ||||||
|  | 	topic       string | ||||||
|  | 	contentType string | ||||||
|  | 	body        []byte | ||||||
| } | } | ||||||
|  |  | ||||||
| func (r *httpMessage) Topic() string { | func (r *httpMessage) Topic() string { | ||||||
|   | |||||||
							
								
								
									
										18
									
								
								request.go
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								request.go
									
									
									
									
									
								
							| @@ -9,25 +9,25 @@ import ( | |||||||
|  |  | ||||||
| type rpcRequest struct { | type rpcRequest struct { | ||||||
| 	rw          io.ReadWriter | 	rw          io.ReadWriter | ||||||
| 	service     string | 	payload     interface{} | ||||||
| 	method      string |  | ||||||
| 	endpoint    string |  | ||||||
| 	target      string |  | ||||||
| 	contentType string |  | ||||||
| 	codec       codec.Codec | 	codec       codec.Codec | ||||||
| 	header      metadata.Metadata | 	header      metadata.Metadata | ||||||
|  | 	method      string | ||||||
|  | 	endpoint    string | ||||||
|  | 	contentType string | ||||||
|  | 	service     string | ||||||
|  | 	target      string | ||||||
| 	body        []byte | 	body        []byte | ||||||
| 	stream      bool | 	stream      bool | ||||||
| 	payload     interface{} |  | ||||||
| } | } | ||||||
|  |  | ||||||
| type rpcMessage struct { | type rpcMessage struct { | ||||||
|  | 	payload     interface{} | ||||||
|  | 	codec       codec.Codec | ||||||
|  | 	header      metadata.Metadata | ||||||
| 	topic       string | 	topic       string | ||||||
| 	contentType string | 	contentType string | ||||||
| 	payload     interface{} |  | ||||||
| 	header      metadata.Metadata |  | ||||||
| 	body        []byte | 	body        []byte | ||||||
| 	codec       codec.Codec |  | ||||||
| } | } | ||||||
|  |  | ||||||
| func (r *rpcRequest) ContentType() string { | func (r *rpcRequest) ContentType() string { | ||||||
|   | |||||||
| @@ -11,10 +11,10 @@ import ( | |||||||
| ) | ) | ||||||
|  |  | ||||||
| type methodType struct { | type methodType struct { | ||||||
| 	method      reflect.Method |  | ||||||
| 	ArgType     reflect.Type | 	ArgType     reflect.Type | ||||||
| 	ReplyType   reflect.Type | 	ReplyType   reflect.Type | ||||||
| 	ContextType reflect.Type | 	ContextType reflect.Type | ||||||
|  | 	method      reflect.Method | ||||||
| 	stream      bool | 	stream      bool | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -21,9 +21,9 @@ const ( | |||||||
| var typeOfError = reflect.TypeOf((*error)(nil)).Elem() | var typeOfError = reflect.TypeOf((*error)(nil)).Elem() | ||||||
|  |  | ||||||
| type handler struct { | type handler struct { | ||||||
| 	method  reflect.Value |  | ||||||
| 	reqType reflect.Type | 	reqType reflect.Type | ||||||
| 	ctxType reflect.Type | 	ctxType reflect.Type | ||||||
|  | 	method  reflect.Value | ||||||
| } | } | ||||||
|  |  | ||||||
| type httpSubscriber struct { | type httpSubscriber struct { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user