umputun / reproxy

Simple edge server / reverse proxy
http://reproxy.io
MIT License
1.21k stars 90 forks source link

Fix redirects #152

Closed ShoshinNikita closed 1 year ago

ShoshinNikita commented 1 year ago

Before this change redirects didn't work because method Service.extendMapper didn't copy the value of URLMapper.RedirectType to the extended result.

To fix this we return the original URLMapper instead of creating a new one (it can also help to avoid similar bugs in the future). We can reuse URLMapper because it is passed by value.

ShoshinNikita commented 1 year ago
2022/11/07 13:47:25 INFO  activate http proxy server on 127.0.0.1:49700
    proxy_test.go:66: 
            Error Trace:    proxy_test.go:66
            Error:          Received unexpected error:
                            Get "http://127.0.0.1:49700/api/something": dial tcp 127.0.0.1:49700: connect: connection refused
            Test:           TestHttp_Do
--- FAIL: TestHttp_Do (0.06s)

I reproduced this fail (~1/50 test runs). It looks like the 10ms delay (app/proxy/proxy_test.go:58) sometimes is not long enough. I can increase it to 20ms, for example. Another option is to just re-run CI.

ShoshinNikita commented 1 year ago
2022/11/07 14:06:38.404 [INFO]  {logger/logger.go:134 logger.(*Middleware).Handler.func1.1} GET - /svc2/test - 127.0.0.1 - 127.0.0.1 - 404 (43) - 169.961115ms
main_test.go:81: 
      Error Trace:  main_test.go:81
      Error:        Not equal: 
                    expected: 200
                    actual  : 404
      Test:         Test_Main
main_test.go:84: 
      Error Trace:  main_test.go:84
      Error:        "404 page not found\n" does not contain "echo echo 123"
      Test:         Test_Main

app/main_test.go:28

"--static.rule=*,/svc2/(.*), https://echo.umputun.com/$1,https://feedmaster.umputun.com/ping",

It looks like https://echo.umputun.com/test doesn't work as expected anymore. I am not sure what caused this. Should I update expected status code and body?

umputun commented 1 year ago

It looks like https://echo.umputun.com/test doesn't work as expected anymore

should be back

ShoshinNikita commented 1 year ago

I think the decrease of coverage by 0.02% is not very critical. Especially, I believe it is caused by code removal.