// Code generated by protoc-gen-go. DO NOT EDIT.
// source: hello.proto

package hello_pb

import (
	fmt "fmt"
	_ "github.com/chai2010/pbgo"
	proto "github.com/golang/protobuf/proto"
	math "math"
)

import (
	context "context"
	encoding_json "encoding/json"
	io "io"
	io_ioutil "io/ioutil"
	net_http "net/http"
	net_rpc "net/rpc"
	regexp "regexp"
	strings "strings"

	github_com_chai2010_pbgo "github.com/chai2010/pbgo"
	github_com_julienschmidt_httprouter "github.com/julienschmidt/httprouter"
)

// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf

// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package

type String struct {
	Value                string   `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (m *String) Reset()         { *m = String{} }
func (m *String) String() string { return proto.CompactTextString(m) }
func (*String) ProtoMessage()    {}
func (*String) Descriptor() ([]byte, []int) {
	return fileDescriptor_61ef911816e0a8ce, []int{0}
}

func (m *String) XXX_Unmarshal(b []byte) error {
	return xxx_messageInfo_String.Unmarshal(m, b)
}
func (m *String) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
	return xxx_messageInfo_String.Marshal(b, m, deterministic)
}
func (m *String) XXX_Merge(src proto.Message) {
	xxx_messageInfo_String.Merge(m, src)
}
func (m *String) XXX_Size() int {
	return xxx_messageInfo_String.Size(m)
}
func (m *String) XXX_DiscardUnknown() {
	xxx_messageInfo_String.DiscardUnknown(m)
}

var xxx_messageInfo_String proto.InternalMessageInfo

func (m *String) GetValue() string {
	if m != nil {
		return m.Value
	}
	return ""
}

type StaticFile struct {
	ContentType          string   `protobuf:"bytes,1,opt,name=content_type,json=contentType,proto3" json:"content_type,omitempty"`
	ContentBody          []byte   `protobuf:"bytes,2,opt,name=content_body,json=contentBody,proto3" json:"content_body,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (m *StaticFile) Reset()         { *m = StaticFile{} }
func (m *StaticFile) String() string { return proto.CompactTextString(m) }
func (*StaticFile) ProtoMessage()    {}
func (*StaticFile) Descriptor() ([]byte, []int) {
	return fileDescriptor_61ef911816e0a8ce, []int{1}
}

func (m *StaticFile) XXX_Unmarshal(b []byte) error {
	return xxx_messageInfo_StaticFile.Unmarshal(m, b)
}
func (m *StaticFile) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
	return xxx_messageInfo_StaticFile.Marshal(b, m, deterministic)
}
func (m *StaticFile) XXX_Merge(src proto.Message) {
	xxx_messageInfo_StaticFile.Merge(m, src)
}
func (m *StaticFile) XXX_Size() int {
	return xxx_messageInfo_StaticFile.Size(m)
}
func (m *StaticFile) XXX_DiscardUnknown() {
	xxx_messageInfo_StaticFile.DiscardUnknown(m)
}

var xxx_messageInfo_StaticFile proto.InternalMessageInfo

func (m *StaticFile) GetContentType() string {
	if m != nil {
		return m.ContentType
	}
	return ""
}

func (m *StaticFile) GetContentBody() []byte {
	if m != nil {
		return m.ContentBody
	}
	return nil
}

type Message struct {
	Value                string            `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
	Array                []int32           `protobuf:"varint,2,rep,packed,name=array,proto3" json:"array,omitempty"`
	Dict                 map[string]string `protobuf:"bytes,3,rep,name=dict,proto3" json:"dict,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
	Subfiled             *String           `protobuf:"bytes,4,opt,name=subfiled,proto3" json:"subfiled,omitempty"`
	XXX_NoUnkeyedLiteral struct{}          `json:"-"`
	XXX_unrecognized     []byte            `json:"-"`
	XXX_sizecache        int32             `json:"-"`
}

func (m *Message) Reset()         { *m = Message{} }
func (m *Message) String() string { return proto.CompactTextString(m) }
func (*Message) ProtoMessage()    {}
func (*Message) Descriptor() ([]byte, []int) {
	return fileDescriptor_61ef911816e0a8ce, []int{2}
}

func (m *Message) XXX_Unmarshal(b []byte) error {
	return xxx_messageInfo_Message.Unmarshal(m, b)
}
func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
	return xxx_messageInfo_Message.Marshal(b, m, deterministic)
}
func (m *Message) XXX_Merge(src proto.Message) {
	xxx_messageInfo_Message.Merge(m, src)
}
func (m *Message) XXX_Size() int {
	return xxx_messageInfo_Message.Size(m)
}
func (m *Message) XXX_DiscardUnknown() {
	xxx_messageInfo_Message.DiscardUnknown(m)
}

var xxx_messageInfo_Message proto.InternalMessageInfo

func (m *Message) GetValue() string {
	if m != nil {
		return m.Value
	}
	return ""
}

func (m *Message) GetArray() []int32 {
	if m != nil {
		return m.Array
	}
	return nil
}

func (m *Message) GetDict() map[string]string {
	if m != nil {
		return m.Dict
	}
	return nil
}

func (m *Message) GetSubfiled() *String {
	if m != nil {
		return m.Subfiled
	}
	return nil
}

func init() {
	proto.RegisterType((*String)(nil), "hello_pb.String")
	proto.RegisterType((*StaticFile)(nil), "hello_pb.StaticFile")
	proto.RegisterType((*Message)(nil), "hello_pb.Message")
	proto.RegisterMapType((map[string]string)(nil), "hello_pb.Message.DictEntry")
}

func init() { proto.RegisterFile("hello.proto", fileDescriptor_61ef911816e0a8ce) }

var fileDescriptor_61ef911816e0a8ce = []byte{
	// 433 bytes of a gzipped FileDescriptorProto
	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0xcb, 0x6e, 0xd3, 0x40,
	0x14, 0xd5, 0xc4, 0x49, 0xda, 0xde, 0xa4, 0x10, 0x46, 0x45, 0x44, 0x06, 0x21, 0xe3, 0x95, 0x17,
	0xc8, 0x2e, 0x2e, 0x08, 0xe4, 0x0d, 0x82, 0xd4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, 0xad, 0xf2, 0xb8, 0x28, 0x08, 0x3b, 0xcc, 0x70, 0x8e, 0x92, 0x69,
	0xf3, 0x89, 0x5c, 0xfc, 0x0f, 0x00, 0x00, 0xff, 0xff, 0x92, 0xb1, 0x61, 0x7f, 0x47, 0x03, 0x00,
	0x00,
}

// Reference imports to suppress errors if they are not otherwise used.
var _ = context.Background
var _ = encoding_json.Marshal
var _ = net_rpc.Server{}
var _ = net_http.ListenAndServe
var _ = io.EOF
var _ = io_ioutil.ReadAll
var _ = regexp.Match
var _ = strings.Split
var _ = github_com_chai2010_pbgo.PopulateFieldFromPath
var _ = github_com_julienschmidt_httprouter.New

type HelloServiceInterface interface {
	Hello(in *String, out *String) error
	Echo(in *Message, out *Message) error
	Static(in *String, out *StaticFile) error
}

type HelloServiceGrpcInterface interface {
	Hello(ctx context.Context, in *String) (out *String, err error)
	Echo(ctx context.Context, in *Message) (out *Message, err error)
	Static(ctx context.Context, in *String) (out *StaticFile, err error)
}

func RegisterHelloService(srv *net_rpc.Server, x HelloServiceInterface) error {
	if _, ok := x.(*HelloServiceValidator); !ok {
		x = &HelloServiceValidator{HelloServiceInterface: x}
	}

	if err := srv.RegisterName("HelloService", x); err != nil {
		return err
	}
	return nil
}

type HelloServiceValidator struct {
	HelloServiceInterface
}

func (p *HelloServiceValidator) Hello(in *String, out *String) error {
	if x, ok := proto.Message(in).(interface{ Validate() error }); ok {
		if err := x.Validate(); err != nil {
			return err
		}
	}

	if err := p.HelloServiceInterface.Hello(in, out); err != nil {
		return err
	}

	if x, ok := proto.Message(out).(interface{ Validate() error }); ok {
		if err := x.Validate(); err != nil {
			return err
		}
	}

	return nil
}

func (p *HelloServiceValidator) Echo(in *Message, out *Message) error {
	if x, ok := proto.Message(in).(interface{ Validate() error }); ok {
		if err := x.Validate(); err != nil {
			return err
		}
	}

	if err := p.HelloServiceInterface.Echo(in, out); err != nil {
		return err
	}

	if x, ok := proto.Message(out).(interface{ Validate() error }); ok {
		if err := x.Validate(); err != nil {
			return err
		}
	}

	return nil
}

func (p *HelloServiceValidator) Static(in *String, out *StaticFile) error {
	if x, ok := proto.Message(in).(interface{ Validate() error }); ok {
		if err := x.Validate(); err != nil {
			return err
		}
	}

	if err := p.HelloServiceInterface.Static(in, out); err != nil {
		return err
	}

	if x, ok := proto.Message(out).(interface{ Validate() error }); ok {
		if err := x.Validate(); err != nil {
			return err
		}
	}

	return nil
}

type HelloServiceClient struct {
	*net_rpc.Client
}

func DialHelloService(network, address string) (*HelloServiceClient, error) {
	c, err := net_rpc.Dial(network, address)
	if err != nil {
		return nil, err
	}
	return &HelloServiceClient{Client: c}, nil
}

func (p *HelloServiceClient) Hello(in *String) (*String, error) {
	if x, ok := proto.Message(in).(interface{ Validate() error }); ok {
		if err := x.Validate(); err != nil {
			return nil, err
		}
	}

	var out = new(String)
	if err := p.Client.Call("HelloService.Hello", in, out); err != nil {
		return nil, err
	}

	if x, ok := proto.Message(out).(interface{ Validate() error }); ok {
		if err := x.Validate(); err != nil {
			return nil, err
		}
	}

	return out, nil
}
func (p *HelloServiceClient) AsyncHello(in *String, out *String, done chan *net_rpc.Call) *net_rpc.Call {
	if x, ok := proto.Message(in).(interface{ Validate() error }); ok {
		if err := x.Validate(); err != nil {
			call := &net_rpc.Call{
				ServiceMethod: "HelloService.Hello",
				Args:          in,
				Reply:         out,
				Error:         err,
				Done:          make(chan *net_rpc.Call, 10),
			}
			call.Done <- call
			return call
		}
	}

	return p.Go(
		"HelloService.Hello",
		in, out,
		done,
	)
}

func (p *HelloServiceClient) Echo(in *Message) (*Message, error) {
	if x, ok := proto.Message(in).(interface{ Validate() error }); ok {
		if err := x.Validate(); err != nil {
			return nil, err
		}
	}

	var out = new(Message)
	if err := p.Client.Call("HelloService.Echo", in, out); err != nil {
		return nil, err
	}

	if x, ok := proto.Message(out).(interface{ Validate() error }); ok {
		if err := x.Validate(); err != nil {
			return nil, err
		}
	}

	return out, nil
}
func (p *HelloServiceClient) AsyncEcho(in *Message, out *Message, done chan *net_rpc.Call) *net_rpc.Call {
	if x, ok := proto.Message(in).(interface{ Validate() error }); ok {
		if err := x.Validate(); err != nil {
			call := &net_rpc.Call{
				ServiceMethod: "HelloService.Echo",
				Args:          in,
				Reply:         out,
				Error:         err,
				Done:          make(chan *net_rpc.Call, 10),
			}
			call.Done <- call
			return call
		}
	}

	return p.Go(
		"HelloService.Echo",
		in, out,
		done,
	)
}

func (p *HelloServiceClient) Static(in *String) (*StaticFile, error) {
	if x, ok := proto.Message(in).(interface{ Validate() error }); ok {
		if err := x.Validate(); err != nil {
			return nil, err
		}
	}

	var out = new(StaticFile)
	if err := p.Client.Call("HelloService.Static", in, out); err != nil {
		return nil, err
	}

	if x, ok := proto.Message(out).(interface{ Validate() error }); ok {
		if err := x.Validate(); err != nil {
			return nil, err
		}
	}

	return out, nil
}
func (p *HelloServiceClient) AsyncStatic(in *String, out *StaticFile, done chan *net_rpc.Call) *net_rpc.Call {
	if x, ok := proto.Message(in).(interface{ Validate() error }); ok {
		if err := x.Validate(); err != nil {
			call := &net_rpc.Call{
				ServiceMethod: "HelloService.Static",
				Args:          in,
				Reply:         out,
				Error:         err,
				Done:          make(chan *net_rpc.Call, 10),
			}
			call.Done <- call
			return call
		}
	}

	return p.Go(
		"HelloService.Static",
		in, out,
		done,
	)
}

type HelloServiceHttpClient struct {
	c       *net_http.Client
	baseurl string
}

func NewHelloServiceHttpClient(baseurl string, c ...*net_http.Client) *HelloServiceHttpClient {
	p := &HelloServiceHttpClient{
		c:       net_http.DefaultClient,
		baseurl: baseurl,
	}
	if len(c) != 0 && c[0] != nil {
		p.c = c[0]
	}
	return p
}

func (p *HelloServiceHttpClient) httpDoRequest(method, urlpath string, in interface{}) (mimeType string, content []byte, err error) {
	req, err := github_com_chai2010_pbgo.NewHttpRequest(method, urlpath, in)
	if err != nil {
		return "", nil, err
	}
	resp, err := p.c.Do(req)
	if err != nil {
		return "", nil, err
	}
	defer resp.Body.Close()

	mimeType = resp.Header.Get("Content-Type")
	content, err = io_ioutil.ReadAll(resp.Body)
	return
}

func (p *HelloServiceHttpClient) Hello(in *String, method ...string) (out *String, err error) {
	if len(method) != 1 {
		return nil, fmt.Errorf("invalid method: %v", method)
	}

	var re = regexp.MustCompile("(\\*|\\:)(\\w|\\.)+")
	_ = re

	out = new(String)
	if method[0] == "DELETE" {
		urlpath := p.baseurl + "/hello"
		err = github_com_chai2010_pbgo.HttpDo(method[0], urlpath, in, out)
		return out, err
	}
	if method[0] == "GET" {
		urlpath := p.baseurl + fmt.Sprintf("/hello/%v", in.Value)
		err = github_com_chai2010_pbgo.HttpDo(method[0], urlpath, in, out)
		return out, err
	}
	if method[0] == "PATCH" {
		urlpath := p.baseurl + "/hello"
		err = github_com_chai2010_pbgo.HttpDo(method[0], urlpath, in, out)
		return out, err
	}
	if method[0] == "POST" {
		urlpath := p.baseurl + "/hello"
		err = github_com_chai2010_pbgo.HttpDo(method[0], urlpath, in, out)
		return out, err
	}

	return nil, fmt.Errorf("invalid method: %v", method)
}

func (p *HelloServiceHttpClient) Echo(in *Message, method ...string) (out *Message, err error) {
	if len(method) == 0 {
		method = []string{"GET"}
	}
	if len(method) != 1 {
		return nil, fmt.Errorf("invalid method: %v", method)
	}

	var re = regexp.MustCompile("(\\*|\\:)(\\w|\\.)+")
	_ = re

	out = new(Message)
	if method[0] == "GET" {
		urlpath := p.baseurl + fmt.Sprintf("/echo/%v", in.Subfiled.Value)
		err = github_com_chai2010_pbgo.HttpDo(method[0], urlpath, in, out)
		return out, err
	}

	return nil, fmt.Errorf("invalid method: %v", method)
}

func (p *HelloServiceHttpClient) Static(in *String, method ...string) (out *StaticFile, err error) {
	if len(method) == 0 {
		method = []string{"GET"}
	}
	if len(method) != 1 {
		return nil, fmt.Errorf("invalid method: %v", method)
	}

	var re = regexp.MustCompile("(\\*|\\:)(\\w|\\.)+")
	_ = re

	out = new(StaticFile)
	if method[0] == "GET" {
		urlpath := p.baseurl + fmt.Sprintf("/static/%v", in.Value)
		mimeType, contentBody, err := p.httpDoRequest(method[0], urlpath, in)
		out.ContentType = mimeType
		out.ContentBody = contentBody
		return out, err
	}

	return nil, fmt.Errorf("invalid method: %v", method)
}

func HelloServiceHandler(svc HelloServiceInterface) net_http.Handler {
	var router = github_com_julienschmidt_httprouter.New()

	var re = regexp.MustCompile("(\\*|\\:)(\\w|\\.)+")
	_ = re

	router.Handle("DELETE", "/hello",
		func(w net_http.ResponseWriter, r *net_http.Request, ps github_com_julienschmidt_httprouter.Params) {
			var (
				protoReq   String
				protoReply String
			)

			if err := github_com_chai2010_pbgo.PopulateQueryParameters(&protoReq, r.URL.Query()); err != nil {
				net_http.Error(w, err.Error(), net_http.StatusBadRequest)
				return
			}

			if x, ok := proto.Message(&protoReq).(interface{ Validate() error }); ok {
				if err := x.Validate(); err != nil {
					net_http.Error(w, err.Error(), net_http.StatusBadRequest)
					return
				}
			}

			if err := svc.Hello(&protoReq, &protoReply); err != nil {
				if pbgoErr, ok := err.(github_com_chai2010_pbgo.Error); ok {
					net_http.Error(w, pbgoErr.Text(), pbgoErr.HttpStatus())
					return
				} else {
					net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
					return
				}
			}

			if x, ok := proto.Message(&protoReply).(interface{ Validate() error }); ok {
				if err := x.Validate(); err != nil {
					net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
					return
				}
			}

			if strings.Contains(r.Header.Get("Accept"), "application/json") {
				w.Header().Set("Content-Type", "application/json")
			} else {
				w.Header().Set("Content-Type", "text/plain")
			}

			if err := encoding_json.NewEncoder(w).Encode(&protoReply); err != nil {
				net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
				return
			}
		},
	)

	router.Handle("GET", "/hello/:value",
		func(w net_http.ResponseWriter, r *net_http.Request, ps github_com_julienschmidt_httprouter.Params) {
			var (
				protoReq   String
				protoReply String
			)

			for _, fieldPath := range re.FindAllString("/hello/:value", -1) {
				fieldPath := strings.TrimLeft(fieldPath, ":*")
				err := github_com_chai2010_pbgo.PopulateFieldFromPath(&protoReq, fieldPath, ps.ByName(fieldPath))
				if err != nil {
					net_http.Error(w, err.Error(), net_http.StatusBadRequest)
					return
				}
			}

			if err := github_com_chai2010_pbgo.PopulateQueryParameters(&protoReq, r.URL.Query()); err != nil {
				net_http.Error(w, err.Error(), net_http.StatusBadRequest)
				return
			}

			if x, ok := proto.Message(&protoReq).(interface{ Validate() error }); ok {
				if err := x.Validate(); err != nil {
					net_http.Error(w, err.Error(), net_http.StatusBadRequest)
					return
				}
			}

			if err := svc.Hello(&protoReq, &protoReply); err != nil {
				if pbgoErr, ok := err.(github_com_chai2010_pbgo.Error); ok {
					net_http.Error(w, pbgoErr.Text(), pbgoErr.HttpStatus())
					return
				} else {
					net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
					return
				}
			}

			if x, ok := proto.Message(&protoReply).(interface{ Validate() error }); ok {
				if err := x.Validate(); err != nil {
					net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
					return
				}
			}

			if strings.Contains(r.Header.Get("Accept"), "application/json") {
				w.Header().Set("Content-Type", "application/json")
			} else {
				w.Header().Set("Content-Type", "text/plain")
			}

			if err := encoding_json.NewEncoder(w).Encode(&protoReply); err != nil {
				net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
				return
			}
		},
	)

	router.Handle("PATCH", "/hello",
		func(w net_http.ResponseWriter, r *net_http.Request, ps github_com_julienschmidt_httprouter.Params) {
			var (
				protoReq   String
				protoReply String
			)

			if err := github_com_chai2010_pbgo.PopulateQueryParameters(&protoReq, r.URL.Query()); err != nil {
				net_http.Error(w, err.Error(), net_http.StatusBadRequest)
				return
			}

			if err := encoding_json.NewDecoder(r.Body).Decode(&protoReq); err != nil && err != io.EOF {
				net_http.Error(w, err.Error(), net_http.StatusBadRequest)
				return
			}

			if x, ok := proto.Message(&protoReq).(interface{ Validate() error }); ok {
				if err := x.Validate(); err != nil {
					net_http.Error(w, err.Error(), net_http.StatusBadRequest)
					return
				}
			}

			if err := svc.Hello(&protoReq, &protoReply); err != nil {
				if pbgoErr, ok := err.(github_com_chai2010_pbgo.Error); ok {
					net_http.Error(w, pbgoErr.Text(), pbgoErr.HttpStatus())
					return
				} else {
					net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
					return
				}
			}

			if x, ok := proto.Message(&protoReply).(interface{ Validate() error }); ok {
				if err := x.Validate(); err != nil {
					net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
					return
				}
			}

			if strings.Contains(r.Header.Get("Accept"), "application/json") {
				w.Header().Set("Content-Type", "application/json")
			} else {
				w.Header().Set("Content-Type", "text/plain")
			}

			if err := encoding_json.NewEncoder(w).Encode(&protoReply); err != nil {
				net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
				return
			}
		},
	)

	router.Handle("POST", "/hello",
		func(w net_http.ResponseWriter, r *net_http.Request, ps github_com_julienschmidt_httprouter.Params) {
			var (
				protoReq   String
				protoReply String
			)

			if err := github_com_chai2010_pbgo.PopulateQueryParameters(&protoReq, r.URL.Query()); err != nil {
				net_http.Error(w, err.Error(), net_http.StatusBadRequest)
				return
			}

			if err := encoding_json.NewDecoder(r.Body).Decode(&protoReq); err != nil && err != io.EOF {
				net_http.Error(w, err.Error(), net_http.StatusBadRequest)
				return
			}

			if x, ok := proto.Message(&protoReq).(interface{ Validate() error }); ok {
				if err := x.Validate(); err != nil {
					net_http.Error(w, err.Error(), net_http.StatusBadRequest)
					return
				}
			}

			if err := svc.Hello(&protoReq, &protoReply); err != nil {
				if pbgoErr, ok := err.(github_com_chai2010_pbgo.Error); ok {
					net_http.Error(w, pbgoErr.Text(), pbgoErr.HttpStatus())
					return
				} else {
					net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
					return
				}
			}

			if x, ok := proto.Message(&protoReply).(interface{ Validate() error }); ok {
				if err := x.Validate(); err != nil {
					net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
					return
				}
			}

			if strings.Contains(r.Header.Get("Accept"), "application/json") {
				w.Header().Set("Content-Type", "application/json")
			} else {
				w.Header().Set("Content-Type", "text/plain")
			}

			if err := encoding_json.NewEncoder(w).Encode(&protoReply); err != nil {
				net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
				return
			}
		},
	)

	router.Handle("GET", "/echo/:subfiled.value",
		func(w net_http.ResponseWriter, r *net_http.Request, ps github_com_julienschmidt_httprouter.Params) {
			var (
				protoReq   Message
				protoReply Message
			)

			for _, fieldPath := range re.FindAllString("/echo/:subfiled.value", -1) {
				fieldPath := strings.TrimLeft(fieldPath, ":*")
				err := github_com_chai2010_pbgo.PopulateFieldFromPath(&protoReq, fieldPath, ps.ByName(fieldPath))
				if err != nil {
					net_http.Error(w, err.Error(), net_http.StatusBadRequest)
					return
				}
			}

			if err := github_com_chai2010_pbgo.PopulateQueryParameters(&protoReq, r.URL.Query()); err != nil {
				net_http.Error(w, err.Error(), net_http.StatusBadRequest)
				return
			}

			if x, ok := proto.Message(&protoReq).(interface{ Validate() error }); ok {
				if err := x.Validate(); err != nil {
					net_http.Error(w, err.Error(), net_http.StatusBadRequest)
					return
				}
			}

			if err := svc.Echo(&protoReq, &protoReply); err != nil {
				if pbgoErr, ok := err.(github_com_chai2010_pbgo.Error); ok {
					net_http.Error(w, pbgoErr.Text(), pbgoErr.HttpStatus())
					return
				} else {
					net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
					return
				}
			}

			if x, ok := proto.Message(&protoReply).(interface{ Validate() error }); ok {
				if err := x.Validate(); err != nil {
					net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
					return
				}
			}

			if strings.Contains(r.Header.Get("Accept"), "application/json") {
				w.Header().Set("Content-Type", "application/json")
			} else {
				w.Header().Set("Content-Type", "text/plain")
			}

			if err := encoding_json.NewEncoder(w).Encode(&protoReply); err != nil {
				net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
				return
			}
		},
	)

	router.Handle("GET", "/static/:value",
		func(w net_http.ResponseWriter, r *net_http.Request, ps github_com_julienschmidt_httprouter.Params) {
			var (
				protoReq   String
				protoReply StaticFile
			)

			for _, fieldPath := range re.FindAllString("/static/:value", -1) {
				fieldPath := strings.TrimLeft(fieldPath, ":*")
				err := github_com_chai2010_pbgo.PopulateFieldFromPath(&protoReq, fieldPath, ps.ByName(fieldPath))
				if err != nil {
					net_http.Error(w, err.Error(), net_http.StatusBadRequest)
					return
				}
			}

			if err := github_com_chai2010_pbgo.PopulateQueryParameters(&protoReq, r.URL.Query()); err != nil {
				net_http.Error(w, err.Error(), net_http.StatusBadRequest)
				return
			}

			if x, ok := proto.Message(&protoReq).(interface{ Validate() error }); ok {
				if err := x.Validate(); err != nil {
					net_http.Error(w, err.Error(), net_http.StatusBadRequest)
					return
				}
			}

			if err := svc.Static(&protoReq, &protoReply); err != nil {
				if pbgoErr, ok := err.(github_com_chai2010_pbgo.Error); ok {
					net_http.Error(w, pbgoErr.Text(), pbgoErr.HttpStatus())
					return
				} else {
					net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
					return
				}
			}

			if x, ok := proto.Message(&protoReply).(interface{ Validate() error }); ok {
				if err := x.Validate(); err != nil {
					net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
					return
				}
			}

			w.Header().Set("Content-Type", protoReply.ContentType)

			if _, err := w.Write(protoReply.ContentBody); err != nil {
				net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
				return
			}
		},
	)

	return router
}

func HelloServiceGrpcHandler(
	ctx context.Context, svc HelloServiceGrpcInterface,
	fnAnnotateContext func(ctx context.Context, req *net_http.Request, methodName string) (context.Context, error),
) net_http.Handler {
	var router = github_com_julienschmidt_httprouter.New()

	var re = regexp.MustCompile("(\\*|\\:)(\\w|\\.)+")
	_ = re

	router.Handle("DELETE", "/hello",
		func(w net_http.ResponseWriter, r *net_http.Request, ps github_com_julienschmidt_httprouter.Params) {
			var (
				protoReq   String
				protoReply *String
				err        error
			)

			if err := github_com_chai2010_pbgo.PopulateQueryParameters(&protoReq, r.URL.Query()); err != nil {
				net_http.Error(w, err.Error(), net_http.StatusBadRequest)
				return
			}

			if x, ok := proto.Message(&protoReq).(interface{ Validate() error }); ok {
				if err := x.Validate(); err != nil {
					net_http.Error(w, err.Error(), net_http.StatusBadRequest)
					return
				}
			}

			if fnAnnotateContext != nil {
				var err error
				ctx, err = fnAnnotateContext(ctx, r, "HelloService.Hello")
				if err != nil {
					net_http.Error(w, err.Error(), net_http.StatusBadRequest)
					return
				}
			}

			if protoReply, err = svc.Hello(ctx, &protoReq); err != nil {
				if pbgoErr, ok := err.(github_com_chai2010_pbgo.Error); ok {
					net_http.Error(w, pbgoErr.Text(), pbgoErr.HttpStatus())
					return
				} else {
					net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
					return
				}
			}

			if x, ok := proto.Message(protoReply).(interface{ Validate() error }); ok {
				if err := x.Validate(); err != nil {
					net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
					return
				}
			}

			if strings.Contains(r.Header.Get("Accept"), "application/json") {
				w.Header().Set("Content-Type", "application/json")
			} else {
				w.Header().Set("Content-Type", "text/plain")
			}

			if err := encoding_json.NewEncoder(w).Encode(&protoReply); err != nil {
				net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
				return
			}
		},
	)

	router.Handle("GET", "/hello/:value",
		func(w net_http.ResponseWriter, r *net_http.Request, ps github_com_julienschmidt_httprouter.Params) {
			var (
				protoReq   String
				protoReply *String
				err        error
			)

			for _, fieldPath := range re.FindAllString("/hello/:value", -1) {
				fieldPath := strings.TrimLeft(fieldPath, ":*")
				err := github_com_chai2010_pbgo.PopulateFieldFromPath(&protoReq, fieldPath, ps.ByName(fieldPath))
				if err != nil {
					net_http.Error(w, err.Error(), net_http.StatusBadRequest)
					return
				}
			}

			if err := github_com_chai2010_pbgo.PopulateQueryParameters(&protoReq, r.URL.Query()); err != nil {
				net_http.Error(w, err.Error(), net_http.StatusBadRequest)
				return
			}

			if x, ok := proto.Message(&protoReq).(interface{ Validate() error }); ok {
				if err := x.Validate(); err != nil {
					net_http.Error(w, err.Error(), net_http.StatusBadRequest)
					return
				}
			}

			if fnAnnotateContext != nil {
				var err error
				ctx, err = fnAnnotateContext(ctx, r, "HelloService.Hello")
				if err != nil {
					net_http.Error(w, err.Error(), net_http.StatusBadRequest)
					return
				}
			}

			if protoReply, err = svc.Hello(ctx, &protoReq); err != nil {
				if pbgoErr, ok := err.(github_com_chai2010_pbgo.Error); ok {
					net_http.Error(w, pbgoErr.Text(), pbgoErr.HttpStatus())
					return
				} else {
					net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
					return
				}
			}

			if x, ok := proto.Message(protoReply).(interface{ Validate() error }); ok {
				if err := x.Validate(); err != nil {
					net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
					return
				}
			}

			if strings.Contains(r.Header.Get("Accept"), "application/json") {
				w.Header().Set("Content-Type", "application/json")
			} else {
				w.Header().Set("Content-Type", "text/plain")
			}

			if err := encoding_json.NewEncoder(w).Encode(&protoReply); err != nil {
				net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
				return
			}
		},
	)

	router.Handle("PATCH", "/hello",
		func(w net_http.ResponseWriter, r *net_http.Request, ps github_com_julienschmidt_httprouter.Params) {
			var (
				protoReq   String
				protoReply *String
				err        error
			)

			if err := github_com_chai2010_pbgo.PopulateQueryParameters(&protoReq, r.URL.Query()); err != nil {
				net_http.Error(w, err.Error(), net_http.StatusBadRequest)
				return
			}

			if err := encoding_json.NewDecoder(r.Body).Decode(&protoReq); err != nil && err != io.EOF {
				net_http.Error(w, err.Error(), net_http.StatusBadRequest)
				return
			}

			if x, ok := proto.Message(&protoReq).(interface{ Validate() error }); ok {
				if err := x.Validate(); err != nil {
					net_http.Error(w, err.Error(), net_http.StatusBadRequest)
					return
				}
			}

			if fnAnnotateContext != nil {
				var err error
				ctx, err = fnAnnotateContext(ctx, r, "HelloService.Hello")
				if err != nil {
					net_http.Error(w, err.Error(), net_http.StatusBadRequest)
					return
				}
			}

			if protoReply, err = svc.Hello(ctx, &protoReq); err != nil {
				if pbgoErr, ok := err.(github_com_chai2010_pbgo.Error); ok {
					net_http.Error(w, pbgoErr.Text(), pbgoErr.HttpStatus())
					return
				} else {
					net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
					return
				}
			}

			if x, ok := proto.Message(protoReply).(interface{ Validate() error }); ok {
				if err := x.Validate(); err != nil {
					net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
					return
				}
			}

			if strings.Contains(r.Header.Get("Accept"), "application/json") {
				w.Header().Set("Content-Type", "application/json")
			} else {
				w.Header().Set("Content-Type", "text/plain")
			}

			if err := encoding_json.NewEncoder(w).Encode(&protoReply); err != nil {
				net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
				return
			}
		},
	)

	router.Handle("POST", "/hello",
		func(w net_http.ResponseWriter, r *net_http.Request, ps github_com_julienschmidt_httprouter.Params) {
			var (
				protoReq   String
				protoReply *String
				err        error
			)

			if err := github_com_chai2010_pbgo.PopulateQueryParameters(&protoReq, r.URL.Query()); err != nil {
				net_http.Error(w, err.Error(), net_http.StatusBadRequest)
				return
			}

			if err := encoding_json.NewDecoder(r.Body).Decode(&protoReq); err != nil && err != io.EOF {
				net_http.Error(w, err.Error(), net_http.StatusBadRequest)
				return
			}

			if x, ok := proto.Message(&protoReq).(interface{ Validate() error }); ok {
				if err := x.Validate(); err != nil {
					net_http.Error(w, err.Error(), net_http.StatusBadRequest)
					return
				}
			}

			if fnAnnotateContext != nil {
				var err error
				ctx, err = fnAnnotateContext(ctx, r, "HelloService.Hello")
				if err != nil {
					net_http.Error(w, err.Error(), net_http.StatusBadRequest)
					return
				}
			}

			if protoReply, err = svc.Hello(ctx, &protoReq); err != nil {
				if pbgoErr, ok := err.(github_com_chai2010_pbgo.Error); ok {
					net_http.Error(w, pbgoErr.Text(), pbgoErr.HttpStatus())
					return
				} else {
					net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
					return
				}
			}

			if x, ok := proto.Message(protoReply).(interface{ Validate() error }); ok {
				if err := x.Validate(); err != nil {
					net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
					return
				}
			}

			if strings.Contains(r.Header.Get("Accept"), "application/json") {
				w.Header().Set("Content-Type", "application/json")
			} else {
				w.Header().Set("Content-Type", "text/plain")
			}

			if err := encoding_json.NewEncoder(w).Encode(&protoReply); err != nil {
				net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
				return
			}
		},
	)

	router.Handle("GET", "/echo/:subfiled.value",
		func(w net_http.ResponseWriter, r *net_http.Request, ps github_com_julienschmidt_httprouter.Params) {
			var (
				protoReq   Message
				protoReply *Message
				err        error
			)

			for _, fieldPath := range re.FindAllString("/echo/:subfiled.value", -1) {
				fieldPath := strings.TrimLeft(fieldPath, ":*")
				err := github_com_chai2010_pbgo.PopulateFieldFromPath(&protoReq, fieldPath, ps.ByName(fieldPath))
				if err != nil {
					net_http.Error(w, err.Error(), net_http.StatusBadRequest)
					return
				}
			}

			if err := github_com_chai2010_pbgo.PopulateQueryParameters(&protoReq, r.URL.Query()); err != nil {
				net_http.Error(w, err.Error(), net_http.StatusBadRequest)
				return
			}

			if x, ok := proto.Message(&protoReq).(interface{ Validate() error }); ok {
				if err := x.Validate(); err != nil {
					net_http.Error(w, err.Error(), net_http.StatusBadRequest)
					return
				}
			}

			if fnAnnotateContext != nil {
				var err error
				ctx, err = fnAnnotateContext(ctx, r, "HelloService.Echo")
				if err != nil {
					net_http.Error(w, err.Error(), net_http.StatusBadRequest)
					return
				}
			}

			if protoReply, err = svc.Echo(ctx, &protoReq); err != nil {
				if pbgoErr, ok := err.(github_com_chai2010_pbgo.Error); ok {
					net_http.Error(w, pbgoErr.Text(), pbgoErr.HttpStatus())
					return
				} else {
					net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
					return
				}
			}

			if x, ok := proto.Message(protoReply).(interface{ Validate() error }); ok {
				if err := x.Validate(); err != nil {
					net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
					return
				}
			}

			if strings.Contains(r.Header.Get("Accept"), "application/json") {
				w.Header().Set("Content-Type", "application/json")
			} else {
				w.Header().Set("Content-Type", "text/plain")
			}

			if err := encoding_json.NewEncoder(w).Encode(&protoReply); err != nil {
				net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
				return
			}
		},
	)

	router.Handle("GET", "/static/:value",
		func(w net_http.ResponseWriter, r *net_http.Request, ps github_com_julienschmidt_httprouter.Params) {
			var (
				protoReq   String
				protoReply *StaticFile
				err        error
			)

			for _, fieldPath := range re.FindAllString("/static/:value", -1) {
				fieldPath := strings.TrimLeft(fieldPath, ":*")
				err := github_com_chai2010_pbgo.PopulateFieldFromPath(&protoReq, fieldPath, ps.ByName(fieldPath))
				if err != nil {
					net_http.Error(w, err.Error(), net_http.StatusBadRequest)
					return
				}
			}

			if err := github_com_chai2010_pbgo.PopulateQueryParameters(&protoReq, r.URL.Query()); err != nil {
				net_http.Error(w, err.Error(), net_http.StatusBadRequest)
				return
			}

			if x, ok := proto.Message(&protoReq).(interface{ Validate() error }); ok {
				if err := x.Validate(); err != nil {
					net_http.Error(w, err.Error(), net_http.StatusBadRequest)
					return
				}
			}

			if fnAnnotateContext != nil {
				var err error
				ctx, err = fnAnnotateContext(ctx, r, "HelloService.Static")
				if err != nil {
					net_http.Error(w, err.Error(), net_http.StatusBadRequest)
					return
				}
			}

			if protoReply, err = svc.Static(ctx, &protoReq); err != nil {
				if pbgoErr, ok := err.(github_com_chai2010_pbgo.Error); ok {
					net_http.Error(w, pbgoErr.Text(), pbgoErr.HttpStatus())
					return
				} else {
					net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
					return
				}
			}

			if x, ok := proto.Message(protoReply).(interface{ Validate() error }); ok {
				if err := x.Validate(); err != nil {
					net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
					return
				}
			}

			w.Header().Set("Content-Type", protoReply.ContentType)

			if _, err := w.Write(protoReply.ContentBody); err != nil {
				net_http.Error(w, err.Error(), net_http.StatusInternalServerError)
				return
			}
		},
	)

	return router
}
