Fix ptr/context
This commit is contained in:
parent
01b315dd82
commit
db9864a3a1
|
@ -56,16 +56,16 @@ func (c *RequestContext) AddTiming(name string, desc string, d time.Duration) {
|
|||
d = 0
|
||||
}
|
||||
|
||||
c.addResponseHeader("Server-Timing", fmt.Sprintf("%d_%s;desc=\"%s\";dur=%.6F", c.timingEvents, name, desc, float64(d.Nanoseconds())/1e6))
|
||||
c.AddResponseHeader("Server-Timing", fmt.Sprintf("%d_%s;desc=\"%s\";dur=%.6F", c.timingEvents, name, desc, float64(d.Nanoseconds())/1e6))
|
||||
c.timingEvents++
|
||||
}
|
||||
|
||||
func (c *RequestContext) AddTimingInformational(name string, desc string) {
|
||||
c.addResponseHeader("Server-Timing", fmt.Sprintf("%d_%s;desc=\"%s\"", c.timingEvents, name, desc))
|
||||
c.AddResponseHeader("Server-Timing", fmt.Sprintf("%d_%s;desc=\"%s\"", c.timingEvents, name, desc))
|
||||
c.timingEvents++
|
||||
}
|
||||
|
||||
func (c *RequestContext) getPath() string {
|
||||
func (c *RequestContext) GetPath() string {
|
||||
if c.fasthttp != nil {
|
||||
return string(c.fasthttp.Path())
|
||||
} else if c.httpRequest != nil {
|
||||
|
@ -75,19 +75,19 @@ func (c *RequestContext) getPath() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func (c *RequestContext) getConnectionTime() time.Time {
|
||||
func (c *RequestContext) GetConnectionTime() time.Time {
|
||||
return c.connTime
|
||||
}
|
||||
|
||||
func (c *RequestContext) getRequestTime() time.Time {
|
||||
func (c *RequestContext) GetRequestTime() time.Time {
|
||||
return c.requestTime
|
||||
}
|
||||
|
||||
func (c *RequestContext) isFastHttp() bool {
|
||||
func (c *RequestContext) IsFastHttp() bool {
|
||||
return c.fasthttp != nil
|
||||
}
|
||||
|
||||
func (c *RequestContext) getTLSServerName() string {
|
||||
func (c *RequestContext) GetTLSServerName() string {
|
||||
if c.fasthttp != nil {
|
||||
return c.fasthttp.TLSConnectionState().ServerName
|
||||
} else if c.httpRequest != nil {
|
||||
|
@ -97,7 +97,7 @@ func (c *RequestContext) getTLSServerName() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func (c *RequestContext) getRequestHeader(name string) string {
|
||||
func (c *RequestContext) GetRequestHeader(name string) string {
|
||||
if c.fasthttp != nil {
|
||||
return string(c.fasthttp.Request.Header.Peek(name))
|
||||
} else if c.httpRequest != nil {
|
||||
|
@ -107,7 +107,7 @@ func (c *RequestContext) getRequestHeader(name string) string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func (c *RequestContext) getResponseHeader(name string) string {
|
||||
func (c *RequestContext) GetResponseHeader(name string) string {
|
||||
if c.fasthttp != nil {
|
||||
return string(c.fasthttp.Response.Header.Peek(name))
|
||||
} else if c.httpWriter != nil {
|
||||
|
@ -117,7 +117,7 @@ func (c *RequestContext) getResponseHeader(name string) string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func (c *RequestContext) addResponseHeader(name string, value string) {
|
||||
func (c *RequestContext) AddResponseHeader(name string, value string) {
|
||||
if c.fasthttp != nil {
|
||||
c.fasthttp.Response.Header.Add(name, value)
|
||||
} else if c.httpWriter != nil {
|
||||
|
@ -125,7 +125,7 @@ func (c *RequestContext) addResponseHeader(name string, value string) {
|
|||
}
|
||||
}
|
||||
|
||||
func (c *RequestContext) setResponseHeader(name string, value string) {
|
||||
func (c *RequestContext) SetResponseHeader(name string, value string) {
|
||||
if c.fasthttp != nil {
|
||||
c.fasthttp.Response.Header.Set(name, value)
|
||||
} else if c.httpWriter != nil {
|
||||
|
@ -133,7 +133,7 @@ func (c *RequestContext) setResponseHeader(name string, value string) {
|
|||
}
|
||||
}
|
||||
|
||||
func (c *RequestContext) serveFile(path string) {
|
||||
func (c *RequestContext) ServeFile(path string) {
|
||||
if c.fasthttp != nil {
|
||||
c.fasthttp.Request.URI().Reset()
|
||||
c.fasthttp.Request.URI().SetPath(path)
|
||||
|
@ -143,7 +143,7 @@ func (c *RequestContext) serveFile(path string) {
|
|||
}
|
||||
}
|
||||
|
||||
func (c *RequestContext) setResponseCode(code int) {
|
||||
func (c *RequestContext) SetResponseCode(code int) {
|
||||
if c.fasthttp != nil {
|
||||
c.fasthttp.Response.SetStatusCode(code)
|
||||
} else if c.httpWriter != nil {
|
||||
|
@ -151,7 +151,7 @@ func (c *RequestContext) setResponseCode(code int) {
|
|||
}
|
||||
}
|
||||
|
||||
func (c *RequestContext) doRedirect(location string, code int) {
|
||||
func (c *RequestContext) DoRedirect(location string, code int) {
|
||||
if c.fasthttp != nil {
|
||||
c.fasthttp.Redirect(location, code)
|
||||
} else if c.httpWriter != nil {
|
||||
|
@ -159,7 +159,7 @@ func (c *RequestContext) doRedirect(location string, code int) {
|
|||
}
|
||||
}
|
||||
|
||||
func (c *RequestContext) isGet() bool {
|
||||
func (c *RequestContext) IsGet() bool {
|
||||
if c.fasthttp != nil {
|
||||
return c.fasthttp.IsGet()
|
||||
} else if c.httpRequest != nil {
|
||||
|
@ -169,7 +169,7 @@ func (c *RequestContext) isGet() bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func (c *RequestContext) isOptions() bool {
|
||||
func (c *RequestContext) IsOptions() bool {
|
||||
if c.fasthttp != nil {
|
||||
return c.fasthttp.IsOptions()
|
||||
} else if c.httpRequest != nil {
|
||||
|
@ -179,7 +179,7 @@ func (c *RequestContext) isOptions() bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func (c *RequestContext) isHead() bool {
|
||||
func (c *RequestContext) IsHead() bool {
|
||||
if c.fasthttp != nil {
|
||||
return c.fasthttp.IsHead()
|
||||
} else if c.httpRequest != nil {
|
||||
|
|
|
@ -15,7 +15,7 @@ import (
|
|||
|
||||
type Server struct {
|
||||
ListenAddress string
|
||||
TLSConfig tlsutils.Configuration
|
||||
TLSConfig *tlsutils.Configuration
|
||||
EnableHTTP2 bool
|
||||
EnableHTTP3 bool
|
||||
Debug bool
|
||||
|
|
Loading…
Reference in a new issue