Help: how to proxy http requests after BasicAuth ?
- Dominant language
- Go
- Stars
- 25.6k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
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)
}
```
Contributor guide
Research direction
The handler h currently ends with ctx.Writef after BasicAuth; start from this handler and the Iris BasicAuth example to identify the framework's request-proxy entry point. Done means authenticated requests for www.test.com are forwarded to http://127.0.0.1:3000 instead of being rendered as text.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100