@@ -39,7 +39,7 @@ func newContext(contextID uint32) proxywasm.HttpContext {
3939
4040// override default
4141func (ctx * httpAuthRandom ) OnHttpRequestHeaders (int , bool ) types.Action {
42- hs , err := proxywasm .HostCallGetHttpRequestHeaders ()
42+ hs , err := proxywasm .GetHttpRequestHeaders ()
4343 if err != nil {
4444 proxywasm .LogCriticalf ("failed to get request headers: %v" , err )
4545 return types .ActionContinue
@@ -48,7 +48,7 @@ func (ctx *httpAuthRandom) OnHttpRequestHeaders(int, bool) types.Action {
4848 proxywasm .LogInfof ("request header: %s: %s" , h [0 ], h [1 ])
4949 }
5050
51- if _ , err := proxywasm .HostCallDispatchHttpCall (
51+ if _ , err := proxywasm .DispatchHttpCall (
5252 clusterName , hs , "" , [][2 ]string {}, 50000 ); err != nil {
5353 proxywasm .LogCriticalf ("dipatch httpcall failed: %v" , err )
5454 }
@@ -60,7 +60,7 @@ func (ctx *httpAuthRandom) OnHttpRequestHeaders(int, bool) types.Action {
6060
6161// override default
6262func (ctx * httpAuthRandom ) OnHttpCallResponse (_ int , bodySize int , _ int ) {
63- hs , err := proxywasm .HostCallGetHttpCallResponseHeaders ()
63+ hs , err := proxywasm .GetHttpCallResponseHeaders ()
6464 if err != nil {
6565
6666 proxywasm .LogCriticalf ("failed to get response body: %v" , err )
@@ -71,29 +71,29 @@ func (ctx *httpAuthRandom) OnHttpCallResponse(_ int, bodySize int, _ int) {
7171 proxywasm .LogInfof ("response header from %s: %s: %s" , clusterName , h [0 ], h [1 ])
7272 }
7373
74- b , err := proxywasm .HostCallGetHttpCallResponseBody (0 , bodySize )
74+ b , err := proxywasm .GetHttpCallResponseBody (0 , bodySize )
7575 if err != nil {
7676 proxywasm .LogCriticalf ("failed to get response body: %v" , err )
77- proxywasm .HostCallResumeHttpRequest ()
77+ proxywasm .ResumeHttpRequest ()
7878 return
7979 }
8080
8181 s := fnv .New32a ()
8282 if _ , err := s .Write (b ); err != nil {
8383 proxywasm .LogCriticalf ("failed to calculate hash: %v" , err )
84- proxywasm .HostCallResumeHttpRequest ()
84+ proxywasm .ResumeHttpRequest ()
8585 return
8686 }
8787
8888 if s .Sum32 ()% 2 == 0 {
8989 proxywasm .LogInfo ("access granted" )
90- proxywasm .HostCallResumeHttpRequest ()
90+ proxywasm .ResumeHttpRequest ()
9191 return
9292 }
9393
9494 msg := "access forbidden"
9595 proxywasm .LogInfo (msg )
96- proxywasm .HostCallSendHttpResponse (403 , [][2 ]string {
96+ proxywasm .SendHttpResponse (403 , [][2 ]string {
9797 {"powered-by" , "proxy-wasm-go-sdk!!" },
9898 }, msg )
9999}
0 commit comments