diff --git a/go.mod b/go.mod index 6620849..b79c692 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,6 @@ module go.unistack.org/micro-server-http/v4 +<<<<<<< HEAD go 1.19 require ( @@ -20,6 +21,27 @@ require ( golang.org/x/tools v0.19.0 // indirect google.golang.org/protobuf v1.33.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect +======= +go 1.22.7 + +toolchain go1.23.3 + +require ( + go.unistack.org/micro-client-http/v3 v3.9.14 + go.unistack.org/micro-codec-yaml/v3 v3.10.2 + go.unistack.org/micro-proto/v3 v3.4.1 + go.unistack.org/micro/v3 v3.10.108 + golang.org/x/net v0.31.0 +) + +require ( + github.com/google/gnostic v0.7.0 // indirect + github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect + golang.org/x/sys v0.27.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20241118233622-e639e219e697 // indirect + google.golang.org/grpc v1.68.0 // indirect + google.golang.org/protobuf v1.35.2 // indirect +>>>>>>> rem/v3 gopkg.in/yaml.v3 v3.0.1 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/go.sum b/go.sum index e31f771..90effc0 100644 --- a/go.sum +++ b/go.sum @@ -171,6 +171,10 @@ cloud.google.com/go/compute v1.14.0/go.mod h1:YfLtxrj9sU4Yxv+sXzZkyPjEyPBZfXHUvj cloud.google.com/go/compute v1.15.1/go.mod h1:bjjoF/NtFUrkD/urWfdHaKuOPDR5nWIs63rR+SXhcpA= cloud.google.com/go/compute v1.18.0/go.mod h1:1X7yHxec2Ga+Ss6jPyjxRxpu2uu7PLgsOVXvgU0yacs= cloud.google.com/go/compute v1.19.0/go.mod h1:rikpw2y+UMidAe9tISo04EHNOIf42RLYF/q8Bs93scU= +<<<<<<< HEAD +======= +cloud.google.com/go/compute v1.19.1/go.mod h1:6ylj3a05WF8leseCdIf77NK0g1ey+nj5IKd5/kvShxE= +>>>>>>> rem/v3 cloud.google.com/go/compute/metadata v0.1.0/go.mod h1:Z1VN+bulIf6bt4P/C37K4DyZYZEXYonfTBHHFPO/4UU= cloud.google.com/go/compute/metadata v0.2.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= cloud.google.com/go/compute/metadata v0.2.1/go.mod h1:jgHgmJd2RKBGzXqF5LR2EZMGxBkeanZ9wwa75XHJgOM= @@ -591,11 +595,19 @@ cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoIS cloud.google.com/go/workflows v1.8.0/go.mod h1:ysGhmEajwZxGn1OhGOGKsTXc5PyxOc0vfKf5Af+to4M= cloud.google.com/go/workflows v1.9.0/go.mod h1:ZGkj1aFIOd9c8Gerkjjq7OW7I5+l6cSvT3ujaO/WwSA= cloud.google.com/go/workflows v1.10.0/go.mod h1:fZ8LmRmZQWacon9UCX1r/g/DfAXx5VcPALq2CxzdePw= +<<<<<<< HEAD +======= +dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= +>>>>>>> rem/v3 dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= gioui.org v0.0.0-20210308172011-57750fc8a0a6/go.mod h1:RSH6KIUZ0p2xy5zHDxgAM4zumjgTw83q2ge/PI+yyw8= git.sr.ht/~sbinet/gg v0.3.1/go.mod h1:KGYtlADtqsqANL9ueOFkWymvzUvLMQllU5Ixo+8v3pc= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +<<<<<<< HEAD +======= +github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= +>>>>>>> rem/v3 github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c/go.mod h1:X0CRv0ky0k6m906ixxpzmDRLvX58TFUKS2eePweuyxk= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/ajstarks/deck v0.0.0-20200831202436-30c9fc6549a9/go.mod h1:JynElWSGnm/4RlzPXRlREEwqTHAN3T56Bv2ITsFT3gY= @@ -632,6 +644,10 @@ github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20220314180256-7f1daf1720fc/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20230105202645-06c439db220b/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +<<<<<<< HEAD +======= +github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +>>>>>>> rem/v3 github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -648,11 +664,19 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.m github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/go-control-plane v0.10.3/go.mod h1:fJJn/j26vwOu972OllsvAgJJM//w9BV6Fxbg2LuVd34= +<<<<<<< HEAD github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/envoyproxy/protoc-gen-validate v0.6.7/go.mod h1:dyJXwwfPK2VSqiB9Klm1J6romD608Ba7Hij42vrOBCo= github.com/envoyproxy/protoc-gen-validate v0.9.1/go.mod h1:OKNgG7TCp5pF4d6XftA0++PMirau2/yoOwVac3AbF2w= github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4= github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94= +======= +github.com/envoyproxy/go-control-plane v0.11.1-0.20230524094728-9239064ad72f/go.mod h1:sfYdkwUW4BA3PbKjySwjJy+O4Pu0h62rlqCMHNk+K+Q= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/envoyproxy/protoc-gen-validate v0.6.7/go.mod h1:dyJXwwfPK2VSqiB9Klm1J6romD608Ba7Hij42vrOBCo= +github.com/envoyproxy/protoc-gen-validate v0.9.1/go.mod h1:OKNgG7TCp5pF4d6XftA0++PMirau2/yoOwVac3AbF2w= +github.com/envoyproxy/protoc-gen-validate v0.10.1/go.mod h1:DRjgyB0I43LtJapqN6NiRwroiAU2PaFuvk/vjgh61ss= +>>>>>>> rem/v3 github.com/flowstack/go-jsonschema v0.1.1/go.mod h1:yL7fNggx1o8rm9RlgXv7hTBWxdBM0rVwpMwimd3F3N0= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= @@ -673,6 +697,10 @@ github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MG github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= +<<<<<<< HEAD +======= +github.com/golang/glog v1.1.0/go.mod h1:pfYeQZ3JWZoXTV5sFc986z3HTpwQs9At6P4ImfuP3NQ= +>>>>>>> rem/v3 github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -702,16 +730,23 @@ github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +<<<<<<< HEAD github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +======= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +>>>>>>> rem/v3 github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/flatbuffers v2.0.8+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= +<<<<<<< HEAD github.com/google/gnostic v0.6.9 h1:ZK/5VhkoX835RikCHpSUJV9a+S3e1zLh59YnyWeBW+0= +======= +>>>>>>> rem/v3 github.com/google/gnostic v0.6.9/go.mod h1:Nm8234We1lq6iB9OmlgNv3nH91XLLVZHCDayfA3xq+E= github.com/google/gnostic v0.7.0 h1:d7EpuFp8vVdML+y0JJJYiKeOLjKTdH/GvVkLOBWqJpw= github.com/google/gnostic v0.7.0/go.mod h1:IAcUyMl6vtC95f60EZ8oXyqTsOersP6HbwjeG7EyDPM= @@ -727,12 +762,20 @@ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +<<<<<<< HEAD github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= +======= +>>>>>>> rem/v3 github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +<<<<<<< HEAD +======= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +>>>>>>> rem/v3 github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -794,8 +837,13 @@ github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa02 github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +<<<<<<< HEAD github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +======= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +>>>>>>> rem/v3 github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= @@ -803,11 +851,19 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lyft/protoc-gen-star v0.6.0/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA= github.com/lyft/protoc-gen-star v0.6.1/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA= +<<<<<<< HEAD +======= +github.com/lyft/protoc-gen-star/v2 v2.0.1/go.mod h1:RcCdONR2ScXaYnQC5tUzxzlpA3WVYF7/opLeUgcQs/o= +>>>>>>> rem/v3 github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-sqlite3 v1.14.14/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8/go.mod h1:mC1jAcsrzbxHt8iiaC+zU4b1ylILSosueou12R++wfY= github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3/go.mod h1:RagcQ7I8IeTMnF8JTXieKnO4Z6JCsikNEzj0DwauVzE= +<<<<<<< HEAD +======= +github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= +>>>>>>> rem/v3 github.com/phpdave11/gofpdf v1.4.2/go.mod h1:zpO6xFn9yxo3YLyMvW8HcKWVdbNqgIfOOp2dXMnm1mY= github.com/phpdave11/gofpdi v1.0.12/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= github.com/phpdave11/gofpdi v1.0.13/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= @@ -820,13 +876,25 @@ github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qR github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +<<<<<<< HEAD +======= +github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= +>>>>>>> rem/v3 github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +<<<<<<< HEAD github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w= github.com/ruudk/golang-pdf417 v0.0.0-20201230142125-a7e3863a1245/go.mod h1:pQAZKsJ8yyVxGRWYNEm9oFB8ieLgKFnamEyDmSA0BRk= +======= +github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w= +github.com/ruudk/golang-pdf417 v0.0.0-20201230142125-a7e3863a1245/go.mod h1:pQAZKsJ8yyVxGRWYNEm9oFB8ieLgKFnamEyDmSA0BRk= +github.com/silas/dag v0.0.0-20220518035006-a7e85ada93c5/go.mod h1:7RTUFBdIRC9nZ7/3RyRNH1bdqIShrDejd1YbLwgPS+I= +>>>>>>> rem/v3 github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= @@ -844,6 +912,10 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +<<<<<<< HEAD +======= +github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +>>>>>>> rem/v3 github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= @@ -866,6 +938,7 @@ go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.opentelemetry.io/proto/otlp v0.15.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= +<<<<<<< HEAD go.unistack.org/micro-codec-yaml/v4 v4.0.0 h1:DK/+fA69gmnvYmGHe3kqVR0pukS8ank5lPG4MfdPQEk= go.unistack.org/micro-codec-yaml/v4 v4.0.0/go.mod h1:UG4ouILbUfgNL7nvp7CpmD2IIzO8bQHjzDIahOvIAgM= go.unistack.org/micro-proto/v4 v4.0.1 h1:2RKHgtCOOcAFgKsnngGK5bqM/6MWXOjVCdw03dbuoF8= @@ -876,6 +949,22 @@ go.unistack.org/protoc-gen-go-micro/v4 v4.0.7 h1:c3CeBvjWV9MBrGGPaQCcHZrnuLY9sVJ go.unistack.org/protoc-gen-go-micro/v4 v4.0.7/go.mod h1:9bsKAlESlPXPBSmY/NDLL//smZbhnEMrnWyG+M8zVFA= go.unistack.org/protoc-gen-go-micro/v4 v4.0.13 h1:7iqOK75ErgGJK6c7SjL7rDy9DBv2IjSFw2OZx5waUo8= go.unistack.org/protoc-gen-go-micro/v4 v4.0.13/go.mod h1:9bsKAlESlPXPBSmY/NDLL//smZbhnEMrnWyG+M8zVFA= +======= +go.opentelemetry.io/proto/otlp v0.19.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= +go.unistack.org/micro-client-http/v3 v3.9.13 h1:KUWkDfA7p+dZEIgSsWuPjfj6yeX8rrnHYwrEjdAZvmU= +go.unistack.org/micro-client-http/v3 v3.9.13/go.mod h1:WmrmeWWKohGn5ODrCr53wUp4pe/ZE6UYdXh7ECgpOH4= +go.unistack.org/micro-client-http/v3 v3.9.14 h1:26BiMcUlGpxpN+S84tpAeMetbd9rbBd+IILq1CkFP2U= +go.unistack.org/micro-client-http/v3 v3.9.14/go.mod h1:KS6qxpxGDQmcszBaJpidc1KOr528QflEKoGopl0qYJ8= +go.unistack.org/micro-codec-yaml/v3 v3.10.2 h1:02I9XzhaBHqZU8Vd5e2zhf8j4foJ4muPT/x4gdR6E4c= +go.unistack.org/micro-codec-yaml/v3 v3.10.2/go.mod h1:A/tYj7x9CRhuin7WxeIvnuo8bMDrZYcJkogVYN8X7rU= +go.unistack.org/micro-proto/v3 v3.4.1 h1:UTjLSRz2YZuaHk9iSlVqqsA50JQNAEK2ZFboGqtEa9Q= +go.unistack.org/micro-proto/v3 v3.4.1/go.mod h1:okx/cnOhzuCX0ggl/vToatbCupi0O44diiiLLsZ93Zo= +go.unistack.org/micro/v3 v3.10.94/go.mod h1:erMgt3Bl7vQQ0e9UpQyR5NlLiZ9pKeEJ9+1tfYFaqUg= +go.unistack.org/micro/v3 v3.10.97 h1:8l7fv+i06/PjPrBBhRC/ZQkWGIOuHPg3jJN0vktYE78= +go.unistack.org/micro/v3 v3.10.97/go.mod h1:YzMldzHN9Ei+zy5t/Psu7RUWDZwUfrNYiStSQtTz90g= +go.unistack.org/micro/v3 v3.10.108 h1:3L7SkilMVLtH8y3pQIPtr3jjQYrf0AMv1oAkoL3nFkE= +go.unistack.org/micro/v3 v3.10.108/go.mod h1:YzMldzHN9Ei+zy5t/Psu7RUWDZwUfrNYiStSQtTz90g= +>>>>>>> rem/v3 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -885,6 +974,10 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +<<<<<<< HEAD +======= +golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= +>>>>>>> rem/v3 golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -941,10 +1034,14 @@ golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +<<<<<<< HEAD golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic= golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +======= +golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +>>>>>>> rem/v3 golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -997,14 +1094,28 @@ golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfS golang.org/x/net v0.0.0-20221012135044-0b7e1fb9d458/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= +<<<<<<< HEAD +======= +golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= +>>>>>>> rem/v3 golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +<<<<<<< HEAD golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +======= +golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= +golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= +golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= +golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo= +golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM= +>>>>>>> rem/v3 golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1033,6 +1144,10 @@ golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri golang.org/x/oauth2 v0.4.0/go.mod h1:RznEsdpjGAINPTOF0UH/t+xJ75L18YO3Ho6Pyn+uRec= golang.org/x/oauth2 v0.5.0/go.mod h1:9/XBHVqLaWO3/BRHs5jbpYCnOZVjj5V0ndyaAM7KB4I= golang.org/x/oauth2 v0.6.0/go.mod h1:ycmewcwgD4Rpr3eZJLSB4Kyyljb3qDh40vJ8STE5HKw= +<<<<<<< HEAD +======= +golang.org/x/oauth2 v0.7.0/go.mod h1:hPLQkd9LyjfXTiRohC/41GhcFqxisoUQ99sCUOHO9x4= +>>>>>>> rem/v3 golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1049,7 +1164,11 @@ golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +<<<<<<< HEAD golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +======= +golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +>>>>>>> rem/v3 golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1122,6 +1241,7 @@ golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220829200755-d48e67d00261/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +<<<<<<< HEAD golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1135,6 +1255,29 @@ golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= +======= +golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= +golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= +golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= +golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= +golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= +golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= +>>>>>>> rem/v3 golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1150,6 +1293,13 @@ golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +<<<<<<< HEAD +======= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= +golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +>>>>>>> rem/v3 golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1216,14 +1366,17 @@ golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +<<<<<<< HEAD golang.org/x/tools v0.11.0 h1:EMCa6U9S2LtZXLAMoWiR/R8dAQFRqbAitmbJ2UKhoi8= golang.org/x/tools v0.11.0/go.mod h1:anzJrxPjNtfgiYQYirP2CPGzGLxrH2u2QBhn6Bf3qY8= golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw= golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc= +======= +golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= +>>>>>>> rem/v3 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= @@ -1439,6 +1592,14 @@ google.golang.org/genproto/googleapis/api v0.0.0-20230525234020-1aefcd67740a/go. google.golang.org/genproto/googleapis/api v0.0.0-20230525234035-dd9d682886f9/go.mod h1:vHYtlOoi6TsQ3Uk2yxR7NI5z8uoV+3pZtR4jmHIkRig= google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234015-3fc162c6f38a/go.mod h1:xURIpW9ES5+/GZhnV6beoEtxQrnkRGIfP5VQG2tCBLc= google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA= +<<<<<<< HEAD +======= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230526203410-71b5a4ffd15e/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9 h1:QCqS/PdaHTSWGvupk2F/ehwHtGc0/GYkT+3GAcR1CCc= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241007155032-5fefd90f89a9/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241118233622-e639e219e697 h1:LWZqQOEjDyONlF1H6afSWpAL/znlREo2tHfLoe+8LMA= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241118233622-e639e219e697/go.mod h1:5uTbfoYQed2U9p3KIj2/Zzm02PYhndfdmML0qC3q3FU= +>>>>>>> rem/v3 google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -1476,8 +1637,19 @@ google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCD google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= +<<<<<<< HEAD google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g= +======= +google.golang.org/grpc v1.52.3/go.mod h1:pu6fVzoFb+NBYNAvQL08ic+lvB2IojljRYuun5vorUY= +google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= +google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g= +google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo= +google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= +google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= +google.golang.org/grpc v1.68.0 h1:aHQeeJbo8zAkAa3pRzrVjZlbz6uSfeOXlJNQM0RAbz0= +google.golang.org/grpc v1.68.0/go.mod h1:fmSPC5AsjSBCK54MyHRx48kpOti1/jRfOlwEWywNjWA= +>>>>>>> rem/v3 google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= @@ -1496,6 +1668,7 @@ google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqw google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.29.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +<<<<<<< HEAD google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= @@ -1504,12 +1677,27 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +======= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= +google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io= +google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +>>>>>>> rem/v3 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +<<<<<<< HEAD gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +======= +>>>>>>> rem/v3 gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= @@ -1561,7 +1749,10 @@ rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8 rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +<<<<<<< HEAD sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= +======= +>>>>>>> rem/v3 diff --git a/handler.go b/handler.go index 803a1c7..32c5f8b 100644 --- a/handler.go +++ b/handler.go @@ -6,9 +6,13 @@ import ( "io" "net/http" "reflect" + "slices" + "strconv" "strings" "sync" + "time" +<<<<<<< HEAD "go.unistack.org/micro/v4/errors" "go.unistack.org/micro/v4/logger" "go.unistack.org/micro/v4/metadata" @@ -16,13 +20,30 @@ import ( "go.unistack.org/micro/v4/server" rhttp "go.unistack.org/micro/v4/util/http" rflutil "go.unistack.org/micro/v4/util/reflect" +======= + "go.unistack.org/micro/v3/errors" + "go.unistack.org/micro/v3/logger" + "go.unistack.org/micro/v3/metadata" + "go.unistack.org/micro/v3/meter" + "go.unistack.org/micro/v3/options" + "go.unistack.org/micro/v3/register" + "go.unistack.org/micro/v3/semconv" + "go.unistack.org/micro/v3/server" + "go.unistack.org/micro/v3/tracer" + rhttp "go.unistack.org/micro/v3/util/http" + rflutil "go.unistack.org/micro/v3/util/reflect" +>>>>>>> rem/v3 ) var ( DefaultErrorHandler = func(ctx context.Context, s interface{}, w http.ResponseWriter, r *http.Request, err error, status int) { w.WriteHeader(status) if _, cerr := w.Write([]byte(err.Error())); cerr != nil { +<<<<<<< HEAD logger.DefaultLogger.Error(ctx, fmt.Sprintf("write failed: %v", cerr)) +======= + logger.DefaultLogger.Error(ctx, "write error", cerr) +>>>>>>> rem/v3 } } DefaultContentType = "application/json" @@ -109,14 +130,22 @@ func (h *Server) HTTPHandlerFunc(handler interface{}) (http.HandlerFunc, error) md = metadata.New(len(r.Header) + 8) } for k, v := range r.Header { +<<<<<<< HEAD md[k] = v[0] +======= + md[k] = strings.Join(v, ", ") +>>>>>>> rem/v3 } md["RemoteAddr"] = r.RemoteAddr md["Method"] = r.Method md["URL"] = r.URL.String() md["Proto"] = r.Proto md["Content-Length"] = fmt.Sprintf("%d", r.ContentLength) +<<<<<<< HEAD md["Transfer-Encoding"] = r.TransferEncoding[0] +======= + md["Transfer-Encoding"] = strings.Join(r.TransferEncoding, ",") +>>>>>>> rem/v3 md["Host"] = r.Host md["RequestURI"] = r.RequestURI if r.TLS != nil { @@ -192,8 +221,12 @@ func (h *Server) HTTPHandlerFunc(handler interface{}) (http.HandlerFunc, error) cf, err := h.newCodec(ct) if err != nil { +<<<<<<< HEAD w.WriteHeader(http.StatusBadRequest) _, _ = w.Write([]byte(err.Error())) +======= + w.WriteHeader(http.StatusUnsupportedMediaType) +>>>>>>> rem/v3 return } @@ -263,17 +296,32 @@ func (h *Server) HTTPHandlerFunc(handler interface{}) (http.HandlerFunc, error) } if nmd, ok := metadata.FromOutgoingContext(fctx); ok { for k, v := range nmd { +<<<<<<< HEAD md[k] = v } } +======= + md.Set(k, v) + } + } + metadata.SetOutgoingContext(ctx, md) +>>>>>>> rem/v3 return err } // wrap the handler func +<<<<<<< HEAD // for i := len(handler.sopts.Hooks); i > 0; i-- { // fn = handler.sopts.Hooks[i-1](fn) // } +======= + h.opts.Hooks.EachNext(func(hook options.Hook) { + if h, ok := hook.(server.HookHandler); ok { + fn = h(fn) + } + }) +>>>>>>> rem/v3 if ct == "application/x-www-form-urlencoded" { cf, err = h.newCodec(DefaultContentType) @@ -290,17 +338,31 @@ func (h *Server) HTTPHandlerFunc(handler interface{}) (http.HandlerFunc, error) w.Header().Set(metadata.HeaderContentType, ct) if md, ok := metadata.FromOutgoingContext(ctx); ok { for k, v := range md { +<<<<<<< HEAD w.Header()[k] = []string{v} +======= + w.Header().Set(k, v) +>>>>>>> rem/v3 } } if md := getRspHeader(ctx); md != nil { for k, v := range md { +<<<<<<< HEAD w.Header()[k] = v +======= + for _, vv := range v { + w.Header().Add(k, vv) + } +>>>>>>> rem/v3 } } if nct := w.Header().Get(metadata.HeaderContentType); nct != ct { if cf, err = h.newCodec(nct); err != nil { +<<<<<<< HEAD h.errorHandler(ctx, nil, w, r, err, http.StatusBadRequest) +======= + h.errorHandler(ctx, nil, w, r, err, http.StatusInternalServerError) +>>>>>>> rem/v3 return } } @@ -321,7 +383,11 @@ func (h *Server) HTTPHandlerFunc(handler interface{}) (http.HandlerFunc, error) } if err != nil && handler.sopts.Logger.V(logger.ErrorLevel) { +<<<<<<< HEAD handler.sopts.Logger.Error(handler.sopts.Context, fmt.Sprintf("handler err: %v", err)) +======= + handler.sopts.Logger.Error(handler.sopts.Context, "handler error", err) +>>>>>>> rem/v3 return } @@ -331,7 +397,11 @@ func (h *Server) HTTPHandlerFunc(handler interface{}) (http.HandlerFunc, error) w.WriteHeader(scode) if _, cerr := w.Write(buf); cerr != nil { +<<<<<<< HEAD handler.sopts.Logger.Error(ctx, fmt.Sprintf("write failed: %v", cerr)) +======= + handler.sopts.Logger.Error(ctx, "write failed", cerr) +>>>>>>> rem/v3 } }, nil } @@ -342,8 +412,11 @@ func (h *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { ct = htype } + ts := time.Now() + ctx := context.WithValue(r.Context(), rspCodeKey{}, &rspCodeVal{}) ctx = context.WithValue(ctx, rspHeaderKey{}, &rspHeaderVal{}) + md, ok := metadata.FromIncomingContext(ctx) if !ok { md = metadata.New(len(r.Header) + 8) @@ -360,13 +433,23 @@ func (h *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { md["Method"] = r.Method md["URL"] = r.URL.String() md["Proto"] = r.Proto +<<<<<<< HEAD md["Content-Length"] = fmt.Sprintf("%d", r.ContentLength) if len(r.TransferEncoding) > 0 { md["Transfer-Encoding"] = r.TransferEncoding[0] +======= + md["ContentLength"] = fmt.Sprintf("%d", r.ContentLength) + if len(r.TransferEncoding) > 0 { + md["TransferEncoding"] = strings.Join(r.TransferEncoding, ",") +>>>>>>> rem/v3 } md["Host"] = r.Host md["RequestURI"] = r.RequestURI ctx = metadata.NewIncomingContext(ctx, md) +<<<<<<< HEAD +======= + ctx = metadata.NewOutgoingContext(ctx, metadata.New(0)) +>>>>>>> rem/v3 path := r.URL.Path if !strings.HasPrefix(path, "/") { @@ -418,21 +501,126 @@ func (h *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { } } + var sp tracer.Span if !match && h.hd != nil { +<<<<<<< HEAD if hdlr, ok := h.hd.(http.Handler); ok { hdlr.ServeHTTP(w, r) +======= + if hdlr, ok := h.hd.Handler().(http.Handler); ok { + endpointName := fmt.Sprintf("%s.%s", hldr.name, hldr.mtype.method.Name) + if !slices.Contains(tracer.DefaultSkipEndpoints, endpointName) { + ctx, sp = h.opts.Tracer.Start(ctx, "rpc-server", + tracer.WithSpanKind(tracer.SpanKindServer), + tracer.WithSpanLabels( + "endpoint", endpointName, + ), + ) + defer func() { + n := GetRspCode(ctx) + if s, _ := sp.Status(); s != tracer.SpanStatusError && n > 399 { + sp.SetStatus(tracer.SpanStatusError, http.StatusText(n)) + } + sp.Finish() + }() + } + + if !slices.Contains(meter.DefaultSkipEndpoints, endpointName) { + h.opts.Meter.Counter(semconv.ServerRequestInflight, "endpoint", endpointName, "server", "http").Inc() + + defer func() { + n := GetRspCode(ctx) + if n > 399 { + h.opts.Meter.Counter(semconv.ServerRequestTotal, "endpoint", endpointName, "server", "http", "status", "success", "code", strconv.Itoa(n)).Inc() + } else { + h.opts.Meter.Counter(semconv.ServerRequestTotal, "endpoint", endpointName, "server", "http", "status", "failure", "code", strconv.Itoa(n)).Inc() + } + te := time.Since(ts) + h.opts.Meter.Summary(semconv.ServerRequestLatencyMicroseconds, "endpoint", endpointName, "server", "http").Update(te.Seconds()) + h.opts.Meter.Histogram(semconv.ServerRequestDurationSeconds, "endpoint", endpointName, "server", "http").Update(te.Seconds()) + h.opts.Meter.Counter(semconv.ServerRequestInflight, "endpoint", endpointName, "server", "http").Dec() + }() + } + + hdlr.ServeHTTP(w, r.WithContext(ctx)) +>>>>>>> rem/v3 return } } else if !match { // check for http.HandlerFunc handlers +<<<<<<< HEAD if ph, _, err := h.pathHandlers.Search(r.Method, r.URL.Path); err == nil { ph.(http.HandlerFunc)(w, r) +======= + if !slices.Contains(tracer.DefaultSkipEndpoints, r.URL.Path) { + ctx, sp = h.opts.Tracer.Start(ctx, "rpc-server", + tracer.WithSpanKind(tracer.SpanKindServer), + tracer.WithSpanLabels( + "endpoint", r.URL.Path, + "server", "http", + ), + ) + + defer func() { + if n := GetRspCode(ctx); n > 399 { + sp.SetStatus(tracer.SpanStatusError, http.StatusText(n)) + } else { + sp.SetStatus(tracer.SpanStatusError, http.StatusText(http.StatusNotFound)) + } + sp.Finish() + }() + } + if ph, _, err := h.pathHandlers.Search(r.Method, r.URL.Path); err == nil { + ph.(http.HandlerFunc)(w, r.WithContext(ctx)) +>>>>>>> rem/v3 return } h.errorHandler(ctx, nil, w, r, fmt.Errorf("not matching route found"), http.StatusNotFound) return } + endpointName := fmt.Sprintf("%s.%s", hldr.name, hldr.mtype.method.Name) + + topts := []tracer.SpanOption{ + tracer.WithSpanKind(tracer.SpanKindServer), + tracer.WithSpanLabels( + "endpoint", endpointName, + "server", "http", + ), + } + + if slices.Contains(tracer.DefaultSkipEndpoints, endpointName) { + topts = append(topts, tracer.WithSpanRecord(false)) + } + + ctx, sp = h.opts.Tracer.Start(ctx, "rpc-server", topts...) + + if !slices.Contains(meter.DefaultSkipEndpoints, handler.name) { + defer func() { + te := time.Since(ts) + h.opts.Meter.Summary(semconv.ServerRequestLatencyMicroseconds, "endpoint", handler.name, "server", "http").Update(te.Seconds()) + h.opts.Meter.Histogram(semconv.ServerRequestDurationSeconds, "endpoint", handler.name, "server", "http").Update(te.Seconds()) + h.opts.Meter.Counter(semconv.ServerRequestInflight, "endpoint", handler.name, "server", "http").Dec() + + n := GetRspCode(ctx) + if n > 399 { + h.opts.Meter.Counter(semconv.ServerRequestTotal, "endpoint", handler.name, "server", "http", "status", "failure", "code", strconv.Itoa(n)).Inc() + } else { + h.opts.Meter.Counter(semconv.ServerRequestTotal, "endpoint", handler.name, "server", "http", "status", "success", "code", strconv.Itoa(n)).Inc() + } + }() + } + + defer func() { + n := GetRspCode(ctx) + if n > 399 { + if s, _ := sp.Status(); s != tracer.SpanStatusError { + sp.SetStatus(tracer.SpanStatusError, http.StatusText(n)) + } + } + sp.Finish() + }() + // get fields from url values if len(r.URL.RawQuery) > 0 { umd, cerr := rflutil.URLMap(r.URL.RawQuery) @@ -527,13 +715,25 @@ func (h *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { } } + if err != nil && sp != nil { + sp.SetStatus(tracer.SpanStatusError, err.Error()) + } + return err } +<<<<<<< HEAD // wrap the handler func // for i := len(handler.sopts.HdlrWrappers); i > 0; i-- { // fn = handler.sopts.HdlrWrappers[i-1](fn) // } +======= + h.opts.Hooks.EachNext(func(hook options.Hook) { + if h, ok := hook.(server.HookHandler); ok { + fn = h(fn) + } + }) +>>>>>>> rem/v3 if ct == "application/x-www-form-urlencoded" { cf, err = h.newCodec(DefaultContentType) @@ -562,7 +762,7 @@ func (h *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { } if nct := w.Header().Get(metadata.HeaderContentType); nct != ct { if cf, err = h.newCodec(nct); err != nil { - h.errorHandler(ctx, nil, w, r, err, http.StatusBadRequest) + h.errorHandler(ctx, nil, w, r, err, http.StatusInternalServerError) return } } @@ -582,17 +782,31 @@ func (h *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { buf, err = cf.Marshal(replyv.Interface()) } +<<<<<<< HEAD if err != nil && handler.sopts.Logger.V(logger.ErrorLevel) { handler.sopts.Logger.Error(handler.sopts.Context, fmt.Sprintf("handler err: %v", err)) return } if nscode := GetRspCode(ctx); nscode != 0 { +======= + if err != nil { + if handler.sopts.Logger.V(logger.ErrorLevel) { + handler.sopts.Logger.Error(handler.sopts.Context, "handler error", err) + } + scode = http.StatusInternalServerError + } else if nscode := GetRspCode(ctx); nscode != 0 { +>>>>>>> rem/v3 scode = nscode } + w.WriteHeader(scode) if _, cerr := w.Write(buf); cerr != nil { +<<<<<<< HEAD handler.sopts.Logger.Error(ctx, fmt.Sprintf("write failed: %v", cerr)) +======= + handler.sopts.Logger.Error(ctx, "respoonse write error", cerr) +>>>>>>> rem/v3 } } diff --git a/handler/generate.go b/handler/generate.go index da07e43..26a389d 100644 --- a/handler/generate.go +++ b/handler/generate.go @@ -2,11 +2,21 @@ package handler import ( // import required packages +<<<<<<< HEAD _ "go.unistack.org/micro-proto/v4/openapiv3" +======= + _ "go.unistack.org/micro-proto/v3/openapiv3" +>>>>>>> rem/v3 ) //go:generate sh -c "curl -L https://github.com/swagger-api/swagger-ui/archive/refs/tags/v4.18.3.zip -o - | bsdtar -C swagger-ui --strip-components=2 -xv swagger-ui-4.18.3/dist && rm swagger-ui/*.map swagger-ui/*-es-*.js swagger-ui/swagger-ui.js swagger-ui/swagger-initializer.js" +<<<<<<< HEAD //go:generate sh -c "protoc -I./ -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v4) --go-micro_out='components=micro|http|server',standalone=false,debug=true,paths=source_relative:./ ./meter/meter.proto" //go:generate sh -c "protoc -I./ -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v4) --go-micro_out='components=micro|http|server',standalone=false,debug=true,paths=source_relative:./ ./health/health.proto" +======= +//go:generate sh -c "protoc -I./ -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go-micro_out='components=micro|http|server',standalone=false,debug=true,paths=source_relative:./ ./meter/meter.proto" + +//go:generate sh -c "protoc -I./ -I$(go list -f '{{ .Dir }}' -m go.unistack.org/micro-proto/v3) --go-micro_out='components=micro|http|server',standalone=false,debug=true,paths=source_relative:./ ./health/health.proto" +>>>>>>> rem/v3 diff --git a/handler/graphql/graphql.go b/handler/graphql/graphql.go new file mode 100644 index 0000000..287fb57 --- /dev/null +++ b/handler/graphql/graphql.go @@ -0,0 +1,77 @@ +//go:build ignore + +package graphql_handler + +import ( + "context" + "fmt" + + "github.com/99designs/gqlgen/graphql" + "go.unistack.org/micro/v3/logger" + "go.unistack.org/micro/v3/store" +) + +var _ graphql.Cache = (*cacheWrapper)(nil) + +type Handler struct { + opts Options +} + +type Option func(*Options) + +type Options struct { + cache *cacheWrapper + Path string +} + +type cacheWrapper struct { + s store.Store + l logger.Logger +} + +func (c *cacheWrapper) Get(ctx context.Context, key string) (interface{}, bool) { + var val interface{} + if err := c.s.Read(ctx, key, val); err != nil && err != store.ErrNotFound { + c.l.Error(ctx, fmt.Sprintf("cache.Get %s failed", key), err) + return nil, false + } + return val, true +} + +func (c *cacheWrapper) Add(ctx context.Context, key string, val interface{}) { + if err := c.s.Write(ctx, key, val); err != nil { + c.l.Error(ctx, fmt.Sprintf("cache.Add %s failed", key), err) + } +} + +func Store(s store.Store) Option { + return func(o *Options) { + if o.cache == nil { + o.cache = &cacheWrapper{} + } + o.cache.s = s + } +} + +func Logger(l logger.Logger) Option { + return func(o *Options) { + if o.cache == nil { + o.cache = &cacheWrapper{} + } + o.cache.l = l + } +} + +func Path(path string) Option { + return func(o *Options) { + o.Path = path + } +} + +func NewHandler(opts ...Option) *Handler { + options := Options{} + for _, o := range opts { + o(&options) + } + return &Handler{opts: options} +} diff --git a/handler/health/health.go b/handler/health/health.go index 595ba52..da36bfc 100644 --- a/handler/health/health.go +++ b/handler/health/health.go @@ -1,4 +1,8 @@ +<<<<<<< HEAD package health // import "go.unistack.org/micro-server-http/v4/handler/health" +======= +package health_handler +>>>>>>> rem/v3 import ( "context" @@ -13,15 +17,30 @@ type Handler struct { opts Options } -type CheckFunc func(context.Context) error +type ( + CheckFunc func(context.Context) error + Option func(*Options) +) -type Option func(*Options) +type Stater interface { + Live() bool + Ready() bool + Health() bool +} type Options struct { - Version string - Name string - LiveChecks []CheckFunc - ReadyChecks []CheckFunc + Version string + Name string + Staters []Stater + LiveChecks []CheckFunc + ReadyChecks []CheckFunc + HealthChecks []CheckFunc +} + +func Service(s ...Stater) Option { + return func(o *Options) { + o.Staters = append(o.Staters, s...) + } } func LiveChecks(fns ...CheckFunc) Option { @@ -36,6 +55,12 @@ func ReadyChecks(fns ...CheckFunc) Option { } } +func HealthChecks(fns ...CheckFunc) Option { + return func(o *Options) { + o.HealthChecks = append(o.HealthChecks, fns...) + } +} + func Name(name string) Option { return func(o *Options) { o.Name = name @@ -56,18 +81,51 @@ func NewHandler(opts ...Option) *Handler { return &Handler{opts: options} } +func (h *Handler) Healthy(ctx context.Context, req *codecpb.Frame, rsp *codecpb.Frame) error { + var err error + + for _, s := range h.opts.Staters { + if !s.Health() { + return errors.ServiceUnavailable(h.opts.Name, "%v", err) + } + } + + for _, fn := range h.opts.HealthChecks { + if err = fn(ctx); err != nil { + return errors.ServiceUnavailable(h.opts.Name, "%v", err) + } + } + + return nil +} + func (h *Handler) Live(ctx context.Context, req *codecpb.Frame, rsp *codecpb.Frame) error { var err error + + for _, s := range h.opts.Staters { + if !s.Live() { + return errors.ServiceUnavailable(h.opts.Name, "%v", err) + } + } + for _, fn := range h.opts.LiveChecks { if err = fn(ctx); err != nil { return errors.ServiceUnavailable(h.opts.Name, "%v", err) } } + return nil } func (h *Handler) Ready(ctx context.Context, req *codecpb.Frame, rsp *codecpb.Frame) error { var err error + + for _, s := range h.opts.Staters { + if !s.Ready() { + return errors.ServiceUnavailable(h.opts.Name, "%v", err) + } + } + for _, fn := range h.opts.ReadyChecks { if err = fn(ctx); err != nil { return errors.ServiceUnavailable(h.opts.Name, "%v", err) diff --git a/handler/health/health.proto b/handler/health/health.proto index 7986943..c664d3d 100644 --- a/handler/health/health.proto +++ b/handler/health/health.proto @@ -1,13 +1,34 @@ syntax = "proto3"; +<<<<<<< HEAD package micro.server.http.v4.handler.health; option go_package = "go.unistack.org/micro-server-http/v4/handler/health;health"; +======= +package micro.server.http.v3.handler.health; +option go_package = "go.unistack.org/micro-server-http/v3/handler/health;health_handler"; +>>>>>>> rem/v3 import "api/annotations.proto"; import "openapiv3/annotations.proto"; import "codec/frame.proto"; service HealthService { + rpc Healthy(micro.codec.Frame) returns (micro.codec.Frame) { + option (micro.openapiv3.openapiv3_operation) = { + operation_id: "Healthy"; + responses: { + default: { + reference: { + _ref: "micro.codec.Frame"; + }; + }; + }; + }; + option (micro.api.http) = { + get: "/health"; + additional_bindings: { get: "/healthz"; } + }; + }; rpc Live(micro.codec.Frame) returns (micro.codec.Frame) { option (micro.openapiv3.openapiv3_operation) = { operation_id: "Live"; @@ -19,7 +40,10 @@ service HealthService { }; }; }; - option (micro.api.http) = { get: "/live"; }; + option (micro.api.http) = { + get: "/live"; + additional_bindings: { get: "/livez"; } + }; }; rpc Ready(micro.codec.Frame) returns (micro.codec.Frame) { option (micro.openapiv3.openapiv3_operation) = { @@ -32,7 +56,9 @@ service HealthService { }; }; }; - option (micro.api.http) = { get: "/ready"; }; + option (micro.api.http) = { get: "/ready"; + additional_bindings: { get: "/readyz"; } + }; }; rpc Version(micro.codec.Frame) returns (micro.codec.Frame) { option (micro.openapiv3.openapiv3_operation) = { diff --git a/handler/health/health_micro.pb.go b/handler/health/health_micro.pb.go index bdd2c9d..5cd7095 100644 --- a/handler/health/health_micro.pb.go +++ b/handler/health/health_micro.pb.go @@ -1,21 +1,42 @@ // Code generated by protoc-gen-go-micro. DO NOT EDIT. // versions: +<<<<<<< HEAD // - protoc-gen-go-micro v4.0.2 // - protoc v4.23.4 +======= +// - protoc-gen-go-micro v3.10.4 +// - protoc v5.28.3 +>>>>>>> rem/v3 // source: health/health.proto -package health +package health_handler import ( context "context" +<<<<<<< HEAD codec "go.unistack.org/micro-proto/v4/codec" +======= + codec "go.unistack.org/micro-proto/v3/codec" + client "go.unistack.org/micro/v3/client" +>>>>>>> rem/v3 ) var ( HealthServiceName = "HealthService" ) +<<<<<<< HEAD +======= + +type HealthServiceClient interface { + Healthy(ctx context.Context, req *codec.Frame, opts ...client.CallOption) (*codec.Frame, error) + Live(ctx context.Context, req *codec.Frame, opts ...client.CallOption) (*codec.Frame, error) + Ready(ctx context.Context, req *codec.Frame, opts ...client.CallOption) (*codec.Frame, error) + Version(ctx context.Context, req *codec.Frame, opts ...client.CallOption) (*codec.Frame, error) +} +>>>>>>> rem/v3 type HealthServiceServer interface { + Healthy(ctx context.Context, req *codec.Frame, rsp *codec.Frame) error Live(ctx context.Context, req *codec.Frame, rsp *codec.Frame) error Ready(ctx context.Context, req *codec.Frame, rsp *codec.Frame) error Version(ctx context.Context, req *codec.Frame, rsp *codec.Frame) error diff --git a/handler/health/health_micro_http.pb.go b/handler/health/health_micro_http.pb.go index e7d8431..6877346 100644 --- a/handler/health/health_micro_http.pb.go +++ b/handler/health/health_micro_http.pb.go @@ -1,11 +1,16 @@ // Code generated by protoc-gen-go-micro. DO NOT EDIT. +<<<<<<< HEAD // protoc-gen-go-micro version: v4.0.2 +======= +// protoc-gen-go-micro version: v3.10.4 +>>>>>>> rem/v3 // source: health/health.proto -package health +package health_handler import ( context "context" +<<<<<<< HEAD codec "go.unistack.org/micro-proto/v4/codec" v4 "go.unistack.org/micro-server-http/v4" options "go.unistack.org/micro/v4/options" @@ -36,12 +41,159 @@ var ( Stream: false, }, } +======= + v31 "go.unistack.org/micro-client-http/v3" + codec "go.unistack.org/micro-proto/v3/codec" + v3 "go.unistack.org/micro-server-http/v3" + client "go.unistack.org/micro/v3/client" + server "go.unistack.org/micro/v3/server" + http "net/http" +>>>>>>> rem/v3 ) +var ( + HealthServiceServerEndpoints = []v3.EndpointMetadata{ + { + Name: "HealthService.Healthy", + Path: "/health", + Method: "GET", + Body: "", + Stream: false, + }, + { + Name: "HealthService.Healthy", + Path: "/healthz", + Method: "GET", + Body: "", + Stream: false, + }, + { + Name: "HealthService.Live", + Path: "/live", + Method: "GET", + Body: "", + Stream: false, + }, + { + Name: "HealthService.Live", + Path: "/livez", + Method: "GET", + Body: "", + Stream: false, + }, + { + Name: "HealthService.Ready", + Path: "/ready", + Method: "GET", + Body: "", + Stream: false, + }, + { + Name: "HealthService.Ready", + Path: "/readyz", + Method: "GET", + Body: "", + Stream: false, + }, + { + Name: "HealthService.Version", + Path: "/version", + Method: "GET", + Body: "", + Stream: false, + }, + } +) + +type healthServiceClient struct { + c client.Client + name string +} + +func NewHealthServiceClient(name string, c client.Client) HealthServiceClient { + return &healthServiceClient{c: c, name: name} +} + +func (c *healthServiceClient) Healthy(ctx context.Context, req *codec.Frame, opts ...client.CallOption) (*codec.Frame, error) { + errmap := make(map[string]interface{}, 1) + errmap["default"] = &codec.Frame{} + opts = append(opts, + v31.ErrorMap(errmap), + ) + opts = append(opts, + v31.Method(http.MethodGet), + v31.Path("/health"), + ) + rsp := &codec.Frame{} + err := c.c.Call(ctx, c.c.NewRequest(c.name, "HealthService.Healthy", req), rsp, opts...) + if err != nil { + return nil, err + } + return rsp, nil +} + +func (c *healthServiceClient) Live(ctx context.Context, req *codec.Frame, opts ...client.CallOption) (*codec.Frame, error) { + errmap := make(map[string]interface{}, 1) + errmap["default"] = &codec.Frame{} + opts = append(opts, + v31.ErrorMap(errmap), + ) + opts = append(opts, + v31.Method(http.MethodGet), + v31.Path("/live"), + ) + rsp := &codec.Frame{} + err := c.c.Call(ctx, c.c.NewRequest(c.name, "HealthService.Live", req), rsp, opts...) + if err != nil { + return nil, err + } + return rsp, nil +} + +func (c *healthServiceClient) Ready(ctx context.Context, req *codec.Frame, opts ...client.CallOption) (*codec.Frame, error) { + errmap := make(map[string]interface{}, 1) + errmap["default"] = &codec.Frame{} + opts = append(opts, + v31.ErrorMap(errmap), + ) + opts = append(opts, + v31.Method(http.MethodGet), + v31.Path("/ready"), + ) + rsp := &codec.Frame{} + err := c.c.Call(ctx, c.c.NewRequest(c.name, "HealthService.Ready", req), rsp, opts...) + if err != nil { + return nil, err + } + return rsp, nil +} + +func (c *healthServiceClient) Version(ctx context.Context, req *codec.Frame, opts ...client.CallOption) (*codec.Frame, error) { + errmap := make(map[string]interface{}, 1) + errmap["default"] = &codec.Frame{} + opts = append(opts, + v31.ErrorMap(errmap), + ) + opts = append(opts, + v31.Method(http.MethodGet), + v31.Path("/version"), + ) + rsp := &codec.Frame{} + err := c.c.Call(ctx, c.c.NewRequest(c.name, "HealthService.Version", req), rsp, opts...) + if err != nil { + return nil, err + } + return rsp, nil +} + type healthServiceServer struct { HealthServiceServer } +func (h *healthServiceServer) Healthy(ctx context.Context, req *codec.Frame, rsp *codec.Frame) error { + return h.HealthServiceServer.Healthy(ctx, req, rsp) +} + func (h *healthServiceServer) Live(ctx context.Context, req *codec.Frame, rsp *codec.Frame) error { return h.HealthServiceServer.Live(ctx, req, rsp) } @@ -56,6 +208,7 @@ func (h *healthServiceServer) Version(ctx context.Context, req *codec.Frame, rsp func RegisterHealthServiceServer(s server.Server, sh HealthServiceServer, opts ...options.Option) error { type healthService interface { + Healthy(ctx context.Context, req *codec.Frame, rsp *codec.Frame) error Live(ctx context.Context, req *codec.Frame, rsp *codec.Frame) error Ready(ctx context.Context, req *codec.Frame, rsp *codec.Frame) error Version(ctx context.Context, req *codec.Frame, rsp *codec.Frame) error diff --git a/handler/meter/meter.go b/handler/meter/meter.go index 30461d9..924e3c3 100644 --- a/handler/meter/meter.go +++ b/handler/meter/meter.go @@ -1,4 +1,8 @@ +<<<<<<< HEAD package meter // import "go.unistack.org/micro-server-http/v4/handler/meter" +======= +package meter_handler +>>>>>>> rem/v3 import ( "bytes" @@ -8,11 +12,18 @@ import ( "strings" "sync" +<<<<<<< HEAD codecpb "go.unistack.org/micro-proto/v4/codec" "go.unistack.org/micro/v4/logger" "go.unistack.org/micro/v4/metadata" "go.unistack.org/micro/v4/meter" "go.unistack.org/micro/v4/options" +======= + codecpb "go.unistack.org/micro-proto/v3/codec" + "go.unistack.org/micro/v3/logger" + "go.unistack.org/micro/v3/metadata" + "go.unistack.org/micro/v3/meter" +>>>>>>> rem/v3 ) const ( @@ -36,7 +47,7 @@ var bufPool = sync.Pool{ var _ MeterServiceServer = (*Handler)(nil) type Handler struct { - opts Options + Options Options } type Option func(*Options) @@ -44,7 +55,11 @@ type Option func(*Options) type Options struct { Meter meter.Meter Name string +<<<<<<< HEAD MeterOptions []options.Option +======= + MeterOptions []meter.Option +>>>>>>> rem/v3 DisableCompress bool } @@ -66,7 +81,11 @@ func DisableCompress(g bool) Option { } } +<<<<<<< HEAD func MeterOptions(opts ...options.Option) Option { +======= +func MeterOptions(opts ...meter.Option) Option { +>>>>>>> rem/v3 return func(o *Options) { o.MeterOptions = append(o.MeterOptions, opts...) } @@ -82,7 +101,7 @@ func NewOptions(opts ...Option) Options { func NewHandler(opts ...Option) *Handler { options := NewOptions(opts...) - return &Handler{opts: options} + return &Handler{Options: options} } func (h *Handler) Metrics(ctx context.Context, req *codecpb.Frame, rsp *codecpb.Frame) error { @@ -97,7 +116,11 @@ func (h *Handler) Metrics(ctx context.Context, req *codecpb.Frame, rsp *codecpb. w := io.Writer(buf) +<<<<<<< HEAD if md, ok := metadata.FromIncomingContext(ctx); gzipAccepted(md) && ok && !h.opts.DisableCompress { +======= + if md, ok := metadata.FromOutgoingContext(ctx); gzipAccepted(md) && ok && !h.Options.DisableCompress { +>>>>>>> rem/v3 omd, _ := metadata.FromOutgoingContext(ctx) omd.Set(contentEncodingHeader, "gzip") gz := gzipPool.Get().(*gzip.Writer) @@ -110,8 +133,13 @@ func (h *Handler) Metrics(ctx context.Context, req *codecpb.Frame, rsp *codecpb. gz.Flush() } +<<<<<<< HEAD if err := h.opts.Meter.Write(w, h.opts.MeterOptions...); err != nil { log.Error(ctx, "http/meter: write failed", err) +======= + if err := h.Options.Meter.Write(w, h.Options.MeterOptions...); err != nil { + log.Error(ctx, "http/meter write failed", err) +>>>>>>> rem/v3 return nil } diff --git a/handler/meter/meter.proto b/handler/meter/meter.proto index ddf23a0..165059e 100644 --- a/handler/meter/meter.proto +++ b/handler/meter/meter.proto @@ -1,7 +1,12 @@ syntax = "proto3"; +<<<<<<< HEAD package micro.server.http.v4.handler.meter; option go_package = "go.unistack.org/micro-server-http/v4/handler/meter;meter"; +======= +package micro.server.http.v3.handler.meter; +option go_package = "go.unistack.org/micro-server-http/v3/handler/meter;meter_handler"; +>>>>>>> rem/v3 import "api/annotations.proto"; import "openapiv3/annotations.proto"; diff --git a/handler/meter/meter_micro.pb.go b/handler/meter/meter_micro.pb.go index 20d349b..3d2104a 100644 --- a/handler/meter/meter_micro.pb.go +++ b/handler/meter/meter_micro.pb.go @@ -1,19 +1,36 @@ // Code generated by protoc-gen-go-micro. DO NOT EDIT. // versions: +<<<<<<< HEAD // - protoc-gen-go-micro v4.0.2 // - protoc v4.23.4 +======= +// - protoc-gen-go-micro v3.10.4 +// - protoc v5.28.3 +>>>>>>> rem/v3 // source: meter/meter.proto -package meter +package meter_handler import ( context "context" +<<<<<<< HEAD codec "go.unistack.org/micro-proto/v4/codec" +======= + codec "go.unistack.org/micro-proto/v3/codec" + client "go.unistack.org/micro/v3/client" +>>>>>>> rem/v3 ) var ( MeterServiceName = "MeterService" ) +<<<<<<< HEAD +======= + +type MeterServiceClient interface { + Metrics(ctx context.Context, req *codec.Frame, opts ...client.CallOption) (*codec.Frame, error) +} +>>>>>>> rem/v3 type MeterServiceServer interface { Metrics(ctx context.Context, req *codec.Frame, rsp *codec.Frame) error diff --git a/handler/meter/meter_micro_http.pb.go b/handler/meter/meter_micro_http.pb.go index a1eb74b..9b52354 100644 --- a/handler/meter/meter_micro_http.pb.go +++ b/handler/meter/meter_micro_http.pb.go @@ -1,11 +1,16 @@ // Code generated by protoc-gen-go-micro. DO NOT EDIT. +<<<<<<< HEAD // protoc-gen-go-micro version: v4.0.2 +======= +// protoc-gen-go-micro version: v3.10.4 +>>>>>>> rem/v3 // source: meter/meter.proto -package meter +package meter_handler import ( context "context" +<<<<<<< HEAD codec "go.unistack.org/micro-proto/v4/codec" v4 "go.unistack.org/micro-server-http/v4" options "go.unistack.org/micro/v4/options" @@ -22,8 +27,55 @@ var ( Stream: false, }, } +======= + v31 "go.unistack.org/micro-client-http/v3" + codec "go.unistack.org/micro-proto/v3/codec" + v3 "go.unistack.org/micro-server-http/v3" + client "go.unistack.org/micro/v3/client" + server "go.unistack.org/micro/v3/server" + http "net/http" +>>>>>>> rem/v3 ) +var ( + MeterServiceServerEndpoints = []v3.EndpointMetadata{ + { + Name: "MeterService.Metrics", + Path: "/metrics", + Method: "GET", + Body: "", + Stream: false, + }, + } +) + +type meterServiceClient struct { + c client.Client + name string +} + +func NewMeterServiceClient(name string, c client.Client) MeterServiceClient { + return &meterServiceClient{c: c, name: name} +} + +func (c *meterServiceClient) Metrics(ctx context.Context, req *codec.Frame, opts ...client.CallOption) (*codec.Frame, error) { + errmap := make(map[string]interface{}, 1) + errmap["default"] = &codec.Frame{} + opts = append(opts, + v31.ErrorMap(errmap), + ) + opts = append(opts, + v31.Method(http.MethodGet), + v31.Path("/metrics"), + ) + rsp := &codec.Frame{} + err := c.c.Call(ctx, c.c.NewRequest(c.name, "MeterService.Metrics", req), rsp, opts...) + if err != nil { + return nil, err + } + return rsp, nil +} + type meterServiceServer struct { MeterServiceServer } diff --git a/handler/pprof/pprof.go b/handler/pprof/pprof.go new file mode 100644 index 0000000..d74f637 --- /dev/null +++ b/handler/pprof/pprof.go @@ -0,0 +1,46 @@ +package pprof_handler + +import ( + "expvar" + "net/http" + "net/http/pprof" + "path" + "strings" +) + +func NewHandler(prefixPath string, initFuncs ...func()) http.HandlerFunc { + for _, fn := range initFuncs { + fn() + } + + return func(w http.ResponseWriter, r *http.Request) { + switch { + case strings.EqualFold(r.RequestURI, prefixPath) && r.RequestURI[len(r.RequestURI)-1] != '/': + http.Redirect(w, r, r.RequestURI+"/", http.StatusMovedPermanently) + case strings.HasPrefix(r.RequestURI, path.Join(prefixPath, "cmdline")): + pprof.Cmdline(w, r) + case strings.HasPrefix(r.RequestURI, path.Join(prefixPath, "profile")): + pprof.Profile(w, r) + case strings.HasPrefix(r.RequestURI, path.Join(prefixPath, "symbol")): + pprof.Symbol(w, r) + case strings.HasPrefix(r.RequestURI, path.Join(prefixPath, "trace")): + pprof.Trace(w, r) + case strings.HasPrefix(r.RequestURI, path.Join(prefixPath, "goroutine")): + pprof.Handler("goroutine").ServeHTTP(w, r) + case strings.HasPrefix(r.RequestURI, path.Join(prefixPath, "threadcreate")): + pprof.Handler("threadcreate").ServeHTTP(w, r) + case strings.HasPrefix(r.RequestURI, path.Join(prefixPath, "mutex")): + pprof.Handler("mutex").ServeHTTP(w, r) + case strings.HasPrefix(r.RequestURI, path.Join(prefixPath, "heap")): + pprof.Handler("heap").ServeHTTP(w, r) + case strings.HasPrefix(r.RequestURI, path.Join(prefixPath, "block")): + pprof.Handler("block").ServeHTTP(w, r) + case strings.HasPrefix(r.RequestURI, path.Join(prefixPath, "allocs")): + pprof.Handler("allocs").ServeHTTP(w, r) + case strings.HasPrefix(r.RequestURI, path.Join(prefixPath, "vars")): + expvar.Handler().ServeHTTP(w, r) + default: + pprof.Index(w, r) + } + } +} diff --git a/handler/swagger-ui/swaggerui.go b/handler/swagger-ui/swaggerui.go index 476061b..c3e1e9a 100644 --- a/handler/swagger-ui/swaggerui.go +++ b/handler/swagger-ui/swaggerui.go @@ -1,4 +1,8 @@ +<<<<<<< HEAD package swaggerui // import "go.unistack.org/micro-server-http/v4/handler/swagger-ui" +======= +package swaggerui_handler +>>>>>>> rem/v3 import ( "embed" diff --git a/handler/swagger-ui/swaggerui_test.go b/handler/swagger-ui/swaggerui_test.go index 0e4d8a3..1a42f9a 100644 --- a/handler/swagger-ui/swaggerui_test.go +++ b/handler/swagger-ui/swaggerui_test.go @@ -1,4 +1,8 @@ +<<<<<<< HEAD package swaggerui +======= +package swaggerui_handler +>>>>>>> rem/v3 import ( "net/http" diff --git a/handler/swagger/swagger.go b/handler/swagger/swagger.go index bc59bd6..21c3be7 100644 --- a/handler/swagger/swagger.go +++ b/handler/swagger/swagger.go @@ -1,11 +1,20 @@ +<<<<<<< HEAD package swagger +======= +package swagger_handler +>>>>>>> rem/v3 import ( "io/fs" "net/http" +<<<<<<< HEAD yamlcodec "go.unistack.org/micro-codec-yaml/v4" rutil "go.unistack.org/micro/v4/util/reflect" +======= + yamlcodec "go.unistack.org/micro-codec-yaml/v3" + rutil "go.unistack.org/micro/v3/util/reflect" +>>>>>>> rem/v3 ) // Handler append to generated swagger data from dst map[string]interface{} diff --git a/http.go b/http.go index 9dfdffd..5124dc6 100644 --- a/http.go +++ b/http.go @@ -11,6 +11,7 @@ import ( "reflect" "strings" "sync" + "sync/atomic" "time" "go.unistack.org/micro/v4/codec" @@ -25,13 +26,20 @@ import ( var _ server.Server = (*Server)(nil) type Server struct { +<<<<<<< HEAD hd interface{} +======= + hd server.Handler +>>>>>>> rem/v3 rsvc *register.Service handlers map[string]interface{} exit chan chan error errorHandler func(context.Context, interface{}, http.ResponseWriter, *http.Request, error, int) pathHandlers *rhttp.Trie opts server.Options + stateLive *atomic.Uint32 + stateReady *atomic.Uint32 + stateHealth *atomic.Uint32 registerRPC bool sync.RWMutex registered bool @@ -58,7 +66,11 @@ func (h *Server) Options() server.Options { return opts } +<<<<<<< HEAD func (h *Server) Init(opts ...options.Option) error { +======= +func (h *Server) Init(opts ...server.Option) error { +>>>>>>> rem/v3 if len(opts) == 0 && h.init { return nil } @@ -111,6 +123,10 @@ func (h *Server) Init(opts ...options.Option) error { h.RUnlock() return err } +<<<<<<< HEAD +======= + +>>>>>>> rem/v3 h.RUnlock() h.Lock() @@ -120,6 +136,7 @@ func (h *Server) Init(opts ...options.Option) error { return nil } +<<<<<<< HEAD func (h *Server) Handle(handler interface{}, opts ...options.Option) error { options := server.NewHandleOptions(opts...) var endpointMetadata []EndpointMetadata @@ -128,6 +145,9 @@ func (h *Server) Handle(handler interface{}, opts ...options.Option) error { endpointMetadata = v } +======= +func (h *Server) Handle(handler server.Handler) error { +>>>>>>> rem/v3 // passed unknown handler hdlr, ok := handler.(*httpHandler) if !ok { @@ -153,8 +173,13 @@ func (h *Server) Handle(handler interface{}, opts ...options.Option) error { return nil } +<<<<<<< HEAD func (h *Server) newHTTPHandler(handler interface{}, opts ...options.Option) *httpHandler { options := server.NewHandleOptions(opts...) +======= +func (h *Server) NewHandler(handler interface{}, opts ...server.HandlerOption) server.Handler { + options := server.NewHandlerOptions(opts...) +>>>>>>> rem/v3 eps := make([]*register.Endpoint, 0, len(options.Metadata)) for name, metadata := range options.Metadata { @@ -185,6 +210,11 @@ func (h *Server) newHTTPHandler(handler interface{}, opts ...options.Option) *ht } */ + registerCORS := false + if v, ok := options.Context.Value(registerCORSHandlerKey{}).(bool); ok && v { + registerCORS = true + } + for hn, md := range options.Metadata { var method reflect.Method mname := hn[strings.Index(hn, ".")+1:] @@ -204,7 +234,11 @@ func (h *Server) newHTTPHandler(handler interface{}, opts ...options.Option) *ht mtype, err := prepareEndpoint(method) if err != nil && h.opts.Logger.V(logger.ErrorLevel) { +<<<<<<< HEAD h.opts.Logger.Error(h.opts.Context, fmt.Sprintf("%v", err)) +======= + h.opts.Logger.Error(h.opts.Context, "endpoint error", err) +>>>>>>> rem/v3 continue } else if mtype == nil { h.opts.Logger.Error(h.opts.Context, fmt.Sprintf("nil mtype for %s", mname)) @@ -217,6 +251,7 @@ func (h *Server) newHTTPHandler(handler interface{}, opts ...options.Option) *ht pth := &patHandler{mtype: mtype, name: name, rcvr: rcvr} hdlr.name = name +<<<<<<< HEAD if err := hdlr.handlers.Insert([]string{md["Method"]}, md["Path"], pth); err != nil { h.opts.Logger.Error(h.opts.Context, fmt.Sprintf("cant add handler for %s %s", md["Method"][0], md["Path"][0])) } @@ -224,6 +259,24 @@ func (h *Server) newHTTPHandler(handler interface{}, opts ...options.Option) *ht if h.registerRPC { h.opts.Logger.Info(h.opts.Context, fmt.Sprintf("register rpc handler for http.MethodPost %s /%s", hn, hn)) if err := hdlr.handlers.Insert([]string{http.MethodPost}, "/"+hn, pth); err != nil { +======= + methods := []string{md["Method"]} + if registerCORS { + methods = append(methods, http.MethodOptions) + } + + if err := hdlr.handlers.Insert(methods, md["Path"], pth); err != nil { + h.opts.Logger.Error(h.opts.Context, fmt.Sprintf("cant add handler for %v %s", methods, md["Path"])) + } + + if h.registerRPC { + methods := []string{http.MethodPost} + if registerCORS { + methods = append(methods, http.MethodOptions) + } + + if err := hdlr.handlers.Insert(methods, "/"+hn, pth); err != nil { +>>>>>>> rem/v3 h.opts.Logger.Error(h.opts.Context, fmt.Sprintf("cant add rpc handler for http.MethodPost %s /%s", hn, hn)) } } @@ -254,7 +307,11 @@ func (h *Server) newHTTPHandler(handler interface{}, opts ...options.Option) *ht mtype, err := prepareEndpoint(method) if err != nil && h.opts.Logger.V(logger.ErrorLevel) { +<<<<<<< HEAD h.opts.Logger.Error(h.opts.Context, fmt.Sprintf("%v", err)) +======= + h.opts.Logger.Error(h.opts.Context, "prepare endpoint error", err) +>>>>>>> rem/v3 continue } else if mtype == nil { h.opts.Logger.Error(h.opts.Context, fmt.Sprintf("nil mtype for %s", mname)) @@ -267,13 +324,32 @@ func (h *Server) newHTTPHandler(handler interface{}, opts ...options.Option) *ht pth := &patHandler{mtype: mtype, name: name, rcvr: rcvr} hdlr.name = name +<<<<<<< HEAD if err := hdlr.handlers.Insert([]string{md.Method}, md.Path, pth); err != nil { +======= + methods := []string{md.Method} + if registerCORS { + methods = append(methods, http.MethodOptions) + } + + if err := hdlr.handlers.Insert(methods, md.Path, pth); err != nil { +>>>>>>> rem/v3 h.opts.Logger.Error(h.opts.Context, fmt.Sprintf("cant add handler for %s %s", md.Method, md.Path)) } if h.registerRPC { +<<<<<<< HEAD h.opts.Logger.Info(h.opts.Context, fmt.Sprintf("register rpc handler for http.MethodPost %s /%s", hn, hn)) if err := hdlr.handlers.Insert([]string{http.MethodPost}, "/"+hn, pth); err != nil { +======= + methods := []string{http.MethodPost} + if registerCORS { + methods = append(methods, http.MethodOptions) + } + + h.opts.Logger.Info(h.opts.Context, fmt.Sprintf("register rpc handler for http.MethodPost %s /%s", hn, hn)) + if err := hdlr.handlers.Insert(methods, "/"+hn, pth); err != nil { +>>>>>>> rem/v3 h.opts.Logger.Error(h.opts.Context, fmt.Sprintf("cant add rpc handler for http.MethodPost %s /%s", hn, hn)) } } @@ -282,6 +358,38 @@ func (h *Server) newHTTPHandler(handler interface{}, opts ...options.Option) *ht return hdlr } +<<<<<<< HEAD +======= +func (h *Server) NewSubscriber(topic string, handler interface{}, opts ...server.SubscriberOption) server.Subscriber { + return newSubscriber(topic, handler, opts...) +} + +func (h *Server) Subscribe(sb server.Subscriber) error { + sub, ok := sb.(*httpSubscriber) + if !ok { + return fmt.Errorf("invalid subscriber: expected *httpSubscriber") + } + if len(sub.handlers) == 0 { + return fmt.Errorf("invalid subscriber: no handler functions") + } + + if err := server.ValidateSubscriber(sb); err != nil { + return err + } + + h.RLock() + _, ok = h.subscribers[sub] + h.RUnlock() + if ok { + return fmt.Errorf("subscriber %v already exists", h) + } + h.Lock() + h.subscribers[sub] = nil + h.Unlock() + return nil +} + +>>>>>>> rem/v3 func (h *Server) Register() error { var eps []*register.Endpoint h.RLock() @@ -332,10 +440,46 @@ func (h *Server) Register() error { } h.Lock() +<<<<<<< HEAD +======= + +>>>>>>> rem/v3 h.registered = true h.rsvc = service h.Unlock() +<<<<<<< HEAD +======= + return nil +} + +func (h *Server) subscribe() error { + config := h.opts + + for sb := range h.subscribers { + handler := h.createSubHandler(sb, config) + var opts []broker.SubscribeOption + if queue := sb.Options().Queue; len(queue) > 0 { + opts = append(opts, broker.SubscribeGroup(queue)) + } + + subCtx := config.Context + if cx := sb.Options().Context; cx != nil { + subCtx = cx + } + opts = append(opts, broker.SubscribeContext(subCtx)) + opts = append(opts, broker.SubscribeAutoAck(sb.Options().AutoAck)) + opts = append(opts, broker.SubscribeBodyOnly(sb.Options().BodyOnly)) + + sub, err := config.Broker.Subscribe(subCtx, sb.Topic(), handler, opts...) + if err != nil { + h.Unlock() + return err + } + h.subscribers[sb] = []broker.Subscriber{sub} + } + +>>>>>>> rem/v3 return nil } @@ -350,7 +494,11 @@ func (h *Server) Deregister() error { } if config.Logger.V(logger.InfoLevel) { +<<<<<<< HEAD config.Logger.Info(config.Context, fmt.Sprintf("Deregistering node: %s", service.Nodes[0].ID)) +======= + config.Logger.Info(config.Context, "Deregistering node: "+service.Nodes[0].ID) +>>>>>>> rem/v3 } if err := server.DefaultDeregisterFunc(service, config); err != nil { @@ -366,6 +514,26 @@ func (h *Server) Deregister() error { } h.registered = false +<<<<<<< HEAD +======= + + subCtx := h.opts.Context + for sb, subs := range h.subscribers { + if cx := sb.Options().Context; cx != nil { + subCtx = cx + } + + for _, sub := range subs { + config.Logger.Info(config.Context, "Unsubscribing from topic: "+sub.Topic()) + if err := sub.Unsubscribe(subCtx); err != nil { + h.Unlock() + config.Logger.Error(config.Context, fmt.Sprintf("failed to unsubscribe topic: %s, error", sb.Topic()), err) + return err + } + } + h.subscribers[sb] = nil + } +>>>>>>> rem/v3 h.Unlock() return nil } @@ -400,7 +568,11 @@ func (h *Server) Start() error { } if config.Logger.V(logger.InfoLevel) { +<<<<<<< HEAD config.Logger.Info(config.Context, fmt.Sprintf("Listening on %s", ts.Addr().String())) +======= + config.Logger.Info(config.Context, "Listening on "+ts.Addr().String()) +>>>>>>> rem/v3 } h.Lock() @@ -440,7 +612,11 @@ func (h *Server) Start() error { if err := config.RegisterCheck(h.opts.Context); err != nil { if config.Logger.V(logger.ErrorLevel) { +<<<<<<< HEAD config.Logger.Error(config.Context, fmt.Sprintf("Server %s-%s register check error: %s", config.Name, config.ID, err)) +======= + config.Logger.Error(config.Context, fmt.Sprintf("Server %s-%s register check error", config.Name, config.ID), err) +>>>>>>> rem/v3 } } else { if err = h.Register(); err != nil { @@ -448,6 +624,10 @@ func (h *Server) Start() error { } } + if err := h.subscribe(); err != nil { + return err + } + fn := handler var hs *http.Server @@ -467,9 +647,18 @@ func (h *Server) Start() error { } go func() { +<<<<<<< HEAD if cerr := hs.Serve(ts); cerr != nil && !errors.Is(cerr, net.ErrClosed) { h.opts.Logger.Error(h.opts.Context, cerr.Error()) } +======= + if cerr := hs.Serve(ts); cerr != nil && !errors.Is(cerr, http.ErrServerClosed) { + h.opts.Logger.Error(h.opts.Context, "serve error", cerr) + } + h.stateLive.Store(0) + h.stateReady.Store(0) + h.stateHealth.Store(0) +>>>>>>> rem/v3 }() go func() { @@ -496,28 +685,48 @@ func (h *Server) Start() error { // nolint: nestif if rerr != nil && registered { if config.Logger.V(logger.ErrorLevel) { +<<<<<<< HEAD config.Logger.Error(config.Context, fmt.Sprintf("Server %s-%s register check error: %s, deregister it", config.Name, config.ID, rerr)) +======= + config.Logger.Error(config.Context, fmt.Sprintf("Server %s-%s register check error, deregister it", config.Name, config.ID), rerr) +>>>>>>> rem/v3 } // deregister self in case of error if err := h.Deregister(); err != nil { if config.Logger.V(logger.ErrorLevel) { +<<<<<<< HEAD config.Logger.Error(config.Context, fmt.Sprintf("Server %s-%s deregister error: %s", config.Name, config.ID, err)) +======= + config.Logger.Error(config.Context, fmt.Sprintf("Server %s-%s deregister error", config.Name, config.ID), err) +>>>>>>> rem/v3 } } } else if rerr != nil && !registered { if config.Logger.V(logger.ErrorLevel) { +<<<<<<< HEAD config.Logger.Error(config.Context, fmt.Sprintf("Server %s-%s register check error: %s", config.Name, config.ID, rerr)) +======= + config.Logger.Error(config.Context, fmt.Sprintf("Server %s-%s register check error", config.Name, config.ID), rerr) +>>>>>>> rem/v3 } continue } if err := h.Register(); err != nil { if config.Logger.V(logger.ErrorLevel) { +<<<<<<< HEAD config.Logger.Error(config.Context, fmt.Sprintf("Server %s-%s register error: %s", config.Name, config.ID, err)) +======= + config.Logger.Error(config.Context, fmt.Sprintf("Server %s-%s register error", config.Name, config.ID), err) +>>>>>>> rem/v3 } } if err := h.Register(); err != nil { +<<<<<<< HEAD config.Logger.Error(config.Context, fmt.Sprintf("Server register error: %s", err)) +======= + config.Logger.Error(config.Context, "Server register error", err) +>>>>>>> rem/v3 } // wait for exit case ch = <-h.exit: @@ -527,6 +736,7 @@ func (h *Server) Start() error { // deregister if err := h.Deregister(); err != nil { +<<<<<<< HEAD config.Logger.Error(config.Context, fmt.Sprintf("Server deregister error: %s", err)) } @@ -538,9 +748,30 @@ func (h *Server) Start() error { err = hs.Close() } +======= + config.Logger.Error(config.Context, "Server deregister error", err) + } + + if err := config.Broker.Disconnect(config.Context); err != nil { + config.Logger.Error(config.Context, "Broker disconnect error", err) + } + + ctx, cancel := context.WithTimeout(context.Background(), h.opts.GracefulTimeout) + defer cancel() + + err := hs.Shutdown(ctx) + if err != nil { + err = hs.Close() + } + +>>>>>>> rem/v3 ch <- err }() + h.stateLive.Store(1) + h.stateReady.Store(1) + h.stateHealth.Store(1) + return nil } @@ -558,13 +789,35 @@ func (h *Server) Name() string { return h.opts.Name } +<<<<<<< HEAD func NewServer(opts ...options.Option) *Server { +======= +func (h *Server) Live() bool { + return h.stateLive.Load() == 1 +} + +func (h *Server) Ready() bool { + return h.stateReady.Load() == 1 +} + +func (h *Server) Health() bool { + return h.stateHealth.Load() == 1 +} + +func NewServer(opts ...server.Option) *Server { +>>>>>>> rem/v3 options := server.NewOptions(opts...) eh := DefaultErrorHandler if v, ok := options.Context.Value(errorHandlerKey{}).(errorHandler); ok && v != nil { eh = v } return &Server{ +<<<<<<< HEAD +======= + stateLive: &atomic.Uint32{}, + stateReady: &atomic.Uint32{}, + stateHealth: &atomic.Uint32{}, +>>>>>>> rem/v3 opts: options, exit: make(chan chan error), errorHandler: eh, diff --git a/message.go b/message.go index 40e14de..394c788 100644 --- a/message.go +++ b/message.go @@ -11,7 +11,6 @@ type httpMessage struct { header metadata.Metadata topic string contentType string - body []byte } func (r *httpMessage) Topic() string { diff --git a/options.go b/options.go index 1ce3695..9b955cb 100644 --- a/options.go +++ b/options.go @@ -69,7 +69,7 @@ func getRspHeader(ctx context.Context) http.Header { // GetRspCode used internally by generated http server handler func GetRspCode(ctx context.Context) int { - var code int + code := int(200) if rsp, ok := ctx.Value(rspCodeKey{}).(*rspCodeVal); ok { code = rsp.code } @@ -86,8 +86,13 @@ func Middleware(mw ...func(http.Handler) http.Handler) options.Option { type serverKey struct{} // HTTPServer provide ability to pass *http.Server +<<<<<<< HEAD func HTTPServer(hs *http.Server) options.Option { return options.ContextOption(serverKey{}, hs) +======= +func HTTPServer(hs *http.Server) server.Option { + return server.SetOption(serverKey{}, hs) +>>>>>>> rem/v3 } type errorHandler func(ctx context.Context, s interface{}, w http.ResponseWriter, r *http.Request, err error, status int) @@ -140,6 +145,13 @@ func RegisterRPCHandler(b bool) options.Option { return options.ContextOption(registerRPCHandlerKey{}, b) } +type registerCORSHandlerKey struct{} + +// RegisterCORSHandler registers cors endpoints with /ServiceName.ServiceEndpoint method POPTIONSOST +func RegisterCORSHandler(b bool) server.HandlerOption { + return server.SetHandlerOption(registerCORSHandlerKey{}, b) +} + type handlerEndpointsKey struct{} type EndpointMetadata struct { diff --git a/request.go b/request.go index bc73260..cbf1737 100644 --- a/request.go +++ b/request.go @@ -47,11 +47,7 @@ func (r *rpcRequest) Header() metadata.Metadata { } func (r *rpcRequest) Read() ([]byte, error) { - f := &codec.Frame{} - if err := r.codec.ReadBody(r.rw, f); err != nil { - return nil, err - } - return f.Data, nil + return nil, nil } func (r *rpcRequest) Stream() bool { diff --git a/subscriber.go b/subscriber.go new file mode 100644 index 0000000..8d7d97a --- /dev/null +++ b/subscriber.go @@ -0,0 +1,202 @@ +package http + +import ( + "context" + "fmt" + "reflect" + "strings" + + "go.unistack.org/micro/v3/broker" + "go.unistack.org/micro/v3/metadata" + "go.unistack.org/micro/v3/options" + "go.unistack.org/micro/v3/register" + "go.unistack.org/micro/v3/server" +) + +var typeOfError = reflect.TypeOf((*error)(nil)).Elem() + +type handler struct { + reqType reflect.Type + ctxType reflect.Type + method reflect.Value +} + +type httpSubscriber struct { + topic string + rcvr reflect.Value + typ reflect.Type + subscriber interface{} + handlers []*handler + endpoints []*register.Endpoint + opts server.SubscriberOptions +} + +func newSubscriber(topic string, sub interface{}, opts ...server.SubscriberOption) server.Subscriber { + options := server.NewSubscriberOptions(opts...) + + var endpoints []*register.Endpoint + var handlers []*handler + + if typ := reflect.TypeOf(sub); typ.Kind() == reflect.Func { + h := &handler{ + method: reflect.ValueOf(sub), + } + + switch typ.NumIn() { + case 1: + h.reqType = typ.In(0) + case 2: + h.ctxType = typ.In(0) + h.reqType = typ.In(1) + } + + handlers = append(handlers, h) + ep := ®ister.Endpoint{ + Name: "Func", + Request: register.ExtractSubValue(typ), + Metadata: metadata.New(2), + } + ep.Metadata.Set("topic", topic) + ep.Metadata.Set("subscriber", "true") + endpoints = append(endpoints, ep) + } else { + hdlr := reflect.ValueOf(sub) + name := reflect.Indirect(hdlr).Type().Name() + + for m := 0; m < typ.NumMethod(); m++ { + method := typ.Method(m) + h := &handler{ + method: method.Func, + } + + switch method.Type.NumIn() { + case 2: + h.reqType = method.Type.In(1) + case 3: + h.ctxType = method.Type.In(1) + h.reqType = method.Type.In(2) + } + + handlers = append(handlers, h) + ep := ®ister.Endpoint{ + Name: name + "." + method.Name, + Request: register.ExtractSubValue(method.Type), + Metadata: metadata.New(2), + } + ep.Metadata.Set("topic", topic) + ep.Metadata.Set("subscriber", "true") + endpoints = append(endpoints, ep) + } + } + + return &httpSubscriber{ + rcvr: reflect.ValueOf(sub), + typ: reflect.TypeOf(sub), + topic: topic, + subscriber: sub, + handlers: handlers, + endpoints: endpoints, + opts: options, + } +} + +func (s *Server) createSubHandler(sb *httpSubscriber, opts server.Options) broker.Handler { + return func(p broker.Event) error { + msg := p.Message() + ct := msg.Header["Content-Type"] + cf, err := s.newCodec(ct) + if err != nil { + return err + } + + hdr := metadata.Copy(msg.Header) + ctx := metadata.NewIncomingContext(context.Background(), hdr) + + results := make(chan error, len(sb.handlers)) + + for i := 0; i < len(sb.handlers); i++ { + handler := sb.handlers[i] + + var isVal bool + var req reflect.Value + + if handler.reqType.Kind() == reflect.Ptr { + req = reflect.New(handler.reqType.Elem()) + } else { + req = reflect.New(handler.reqType) + isVal = true + } + if isVal { + req = req.Elem() + } + + if err := cf.Unmarshal(msg.Body, req.Interface()); err != nil { + return err + } + + fn := func(ctx context.Context, msg server.Message) error { + var vals []reflect.Value + if sb.typ.Kind() != reflect.Func { + vals = append(vals, sb.rcvr) + } + if handler.ctxType != nil { + vals = append(vals, reflect.ValueOf(ctx)) + } + + vals = append(vals, reflect.ValueOf(msg.Body())) + + returnValues := handler.method.Call(vals) + if err := returnValues[0].Interface(); err != nil { + return err.(error) + } + return nil + } + + opts.Hooks.EachNext(func(hook options.Hook) { + if h, ok := hook.(server.HookSubHandler); ok { + fn = h(fn) + } + }) + + go func() { + results <- fn(ctx, &httpMessage{ + topic: sb.topic, + contentType: ct, + payload: req.Interface(), + header: msg.Header, + codec: cf, + }) + }() + } + + var errors []string + + for i := 0; i < len(sb.handlers); i++ { + if err := <-results; err != nil { + errors = append(errors, err.Error()) + } + } + + if len(errors) > 0 { + return fmt.Errorf("subscriber error: %s", strings.Join(errors, "\n")) + } + + return nil + } +} + +func (s *httpSubscriber) Topic() string { + return s.topic +} + +func (s *httpSubscriber) Subscriber() interface{} { + return s.subscriber +} + +func (s *httpSubscriber) Endpoints() []*register.Endpoint { + return s.endpoints +} + +func (s *httpSubscriber) Options() server.SubscriberOptions { + return s.opts +} diff --git a/util_test.go b/util_test.go index 515f734..2e96025 100644 --- a/util_test.go +++ b/util_test.go @@ -7,9 +7,57 @@ import ( "strings" "testing" +<<<<<<< HEAD "go.unistack.org/micro/v4/metadata" +======= + "go.unistack.org/micro/v3/metadata" + "go.unistack.org/micro/v3/options" + "go.unistack.org/micro/v3/server" +>>>>>>> rem/v3 ) +func Test_Hook(t *testing.T) { + opts := server.Options{} + + var fn server.HandlerFunc = func(fctx context.Context, req server.Request, rsp interface{}) (err error) { + // fmt.Println("1") + return nil + } + + var fn2 server.HandlerWrapper = func(next server.HandlerFunc) server.HandlerFunc { + return func(ctx context.Context, req server.Request, rsp interface{}) error { + // fmt.Println("2") + return next(ctx, req, rsp) + } + } + var fn3 server.HandlerWrapper = func(next server.HandlerFunc) server.HandlerFunc { + return func(ctx context.Context, req server.Request, rsp interface{}) error { + // fmt.Println("3") + return next(ctx, req, rsp) + } + } + var fn4 server.HandlerWrapper = func(next server.HandlerFunc) server.HandlerFunc { + return func(ctx context.Context, req server.Request, rsp interface{}) error { + // fmt.Println("4") + return next(ctx, req, rsp) + } + } + + opts.Hooks = append(opts.Hooks, fn2, fn3, fn4) + + opts.Hooks.EachNext(func(hook options.Hook) { + if h, ok := hook.(server.HandlerWrapper); ok { + // fmt.Printf("h %#+v\n", h) + fn = h(fn) + } + }) + + err := fn(nil, nil, nil) + if err != nil { + t.Fatal(err) + } +} + func TestFillrequest(t *testing.T) { md := metadata.New(1) md.Set("ClientID", "xxx")