iris icon indicating copy to clipboard operation
iris copied to clipboard

Help: how to proxy http requests after BasicAuth ?

Open herugen opened this issue 4 years ago • 0 comments

Condition: I want to use iris's http basic auth feature to add login function to my web service. The procedure I expect is as follow: a. user visit my web service, like www.test.com b. iris's basic auth do the password validation c. after authentication, iris proxy all the http request to my web service, like http://127.0.0.1:3000

Question: I've done with the basic auth function following your example, and the login function is ok, but how should I do to proxy the http requests to my local service? What codes shuold be to proxy instead of ctx.Writef? Please help me with this, thanks a lot!

func h(ctx iris.Context) {
    username, password, _ := ctx.Request().BasicAuth()
    ctx.Writef("%s %s:%s", ctx.Path(), username, password)
}

herugen avatar Mar 27 '21 17:03 herugen