mirror of
https://github.com/eolinker/apinto
synced 2025-09-27 21:22:24 +08:00
37 lines
794 B
Go
37 lines
794 B
Go
package http_context
|
|
|
|
import http_service "github.com/eolinker/eosc/eocontext/http-context"
|
|
|
|
type requestAgent struct {
|
|
http_service.IRequest
|
|
host string
|
|
hostAgent *UrlAgent
|
|
}
|
|
|
|
func newRequestAgent(IRequest http_service.IRequest, host string) *requestAgent {
|
|
return &requestAgent{IRequest: IRequest, host: host}
|
|
}
|
|
func (a *requestAgent) URI() http_service.IURIWriter {
|
|
if a.hostAgent == nil {
|
|
a.hostAgent = NewUrlAgent(a.IRequest.URI(), a.host)
|
|
}
|
|
return a.hostAgent
|
|
}
|
|
|
|
type UrlAgent struct {
|
|
http_service.IURIWriter
|
|
host string
|
|
}
|
|
|
|
func (u *UrlAgent) Host() string {
|
|
return u.host
|
|
}
|
|
|
|
func (u *UrlAgent) SetHost(host string) {
|
|
u.host = host
|
|
}
|
|
|
|
func NewUrlAgent(IURIWriter http_service.IURIWriter, host string) *UrlAgent {
|
|
return &UrlAgent{IURIWriter: IURIWriter, host: host}
|
|
}
|