From 517eb1652a49e2879f4cc00f9db17488cf574264 Mon Sep 17 00:00:00 2001 From: WeebDataHoarder <57538841+WeebDataHoarder@users.noreply.github.com> Date: Tue, 7 Jun 2022 01:08:57 +0200 Subject: [PATCH] Implement GetHost() --- httputils/fasthttp.go | 4 ++++ httputils/nethttp.go | 4 ++++ httputils/server.go | 1 + 3 files changed, 9 insertions(+) diff --git a/httputils/fasthttp.go b/httputils/fasthttp.go index a31bba4..c6529a1 100644 --- a/httputils/fasthttp.go +++ b/httputils/fasthttp.go @@ -65,6 +65,10 @@ func (c *FastHTTPContext) GetTLSServerName() string { return c.ctx.TLSConnectionState().ServerName } +func (c *FastHTTPContext) GetHost() string { + return string(c.ctx.Request.Host()) +} + func (c *FastHTTPContext) GetRequestHeader(name string) string { return string(c.ctx.Request.Header.Peek(name)) } diff --git a/httputils/nethttp.go b/httputils/nethttp.go index c97367f..c22bce4 100644 --- a/httputils/nethttp.go +++ b/httputils/nethttp.go @@ -65,6 +65,10 @@ func (c *NetHTTPContext) GetTLSServerName() string { return c.httpRequest.TLS.ServerName } +func (c *NetHTTPContext) GetHost() string { + return c.httpRequest.Host +} + func (c *NetHTTPContext) GetRequestHeader(name string) string { return c.httpRequest.Header.Get(name) diff --git a/httputils/server.go b/httputils/server.go index 709d40f..3baa5d1 100644 --- a/httputils/server.go +++ b/httputils/server.go @@ -39,6 +39,7 @@ type RequestContext interface { GetRequestTime() time.Time GetTLSServerName() string GetBody() io.Reader + GetHost() string GetRequestHeader(name string) string GetResponseHeader(name string) string AddResponseHeader(name string, value string)