working commit

This commit is contained in:
2026-02-23 00:07:38 +02:00
parent 685880c8a8
commit b6efc19f7a
41 changed files with 11938 additions and 93 deletions
+3 -1
View File
@@ -124,7 +124,7 @@ func (rctx *Context) SetStatus(httpStatus int) {
}
func (rctx *Context) SendJSON(statusCode int, payload any) {
rctx.StatusCode = statusCode
buffer := bytes.NewBuffer(nil)
json.NewEncoder(buffer).Encode(payload)
rctx.Writer.Header().Set("Content-Type", "application/json")
@@ -135,6 +135,7 @@ func (rctx *Context) SendJSON(statusCode int, payload any) {
}
func (rctx *Context) SendText(statusCode int, payload string) {
rctx.StatusCode = statusCode
size := strconv.FormatInt(int64(len(payload)), 10)
rctx.Writer.Header().Set("Content-Type", "text/plain")
rctx.Writer.Header().Set("Content-Length", size)
@@ -143,6 +144,7 @@ func (rctx *Context) SendText(statusCode int, payload string) {
}
func (rctx *Context) SendBytes(statusCode int, ctype string, payload []byte) {
rctx.StatusCode = statusCode
size := strconv.FormatInt(int64(len(payload)), 10)
rctx.Writer.Header().Set("Content-Type", ctype)
rctx.Writer.Header().Set("Content-Length", size)
+3 -2
View File
@@ -30,7 +30,8 @@ func newLoggingHandler(next Handler, print func(string, ...any)) *loggingHandler
func (logging loggingHandler) ServeHTTP(rctx *Context) {
logging.next.ServeHTTP(rctx)
logging.printFunc("%s %s %s %s %d", rctx.Request.RemoteAddr,
cl := rctx.Writer.Header().Get("Content-Length")
logging.printFunc("%s %s %s %s %s %d", rctx.Request.RemoteAddr,
rctx.Request.Method, rctx.Request.URL.String(),
rctx.Request.Proto, rctx.StatusCode)
rctx.Request.Proto, cl, rctx.StatusCode)
}