working commit
This commit is contained in:
+14
-8
@@ -25,6 +25,7 @@ func NewContext(writer http.ResponseWriter, request *http.Request) *Context {
|
||||
return rctx
|
||||
}
|
||||
|
||||
// Request
|
||||
func (rctx *Context) GetSubpath(key string) (string, bool) {
|
||||
value, exists := rctx.PathMap[key]
|
||||
return value, exists
|
||||
@@ -34,6 +35,19 @@ func (rctx *Context) GetQuery(key string) string {
|
||||
return rctx.Request.URL.Query().Get(key)
|
||||
}
|
||||
|
||||
func (rctx *Context) GetHeader(key string) string {
|
||||
return rctx.Request.Header.Get(key)
|
||||
}
|
||||
|
||||
func (rctx *Context) GetHeaders() http.Header {
|
||||
return rctx.Request.Header
|
||||
}
|
||||
|
||||
func (rctx *Context) GetContext() context.Context {
|
||||
return rctx.Request.Context()
|
||||
}
|
||||
|
||||
// Response
|
||||
func (rctx *Context) SetHeader(key, value string) {
|
||||
rctx.Writer.Header().Set(key, value)
|
||||
}
|
||||
@@ -52,11 +66,3 @@ func (rctx *Context) SendText(payload string) {
|
||||
rctx.Writer.Header().Set("Content-Type", "text/plain")
|
||||
rctx.Writer.Write([]byte(payload))
|
||||
}
|
||||
|
||||
func (rctx *Context) GetHeader(key string) string {
|
||||
return rctx.Request.Header.Get(key)
|
||||
}
|
||||
|
||||
func (rctx *Context) GetContext() context.Context {
|
||||
return rctx.Request.Context()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user