2024-12-29 23:15:44 +00:00
|
|
|
package processor
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"net/http"
|
|
|
|
|
2025-01-03 00:08:22 +00:00
|
|
|
"git.optclblast.xyz/draincloud/draincloud-core/internal/handler"
|
2024-12-29 23:15:44 +00:00
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ginWriter struct {
|
|
|
|
ctx *gin.Context
|
|
|
|
}
|
|
|
|
|
|
|
|
func wrapGin(ctx *gin.Context) ginWriter {
|
|
|
|
return ginWriter{
|
|
|
|
ctx: ctx,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-01-03 00:08:22 +00:00
|
|
|
func (w ginWriter) Write(ctx context.Context, resp any, opts ...handler.WriteOption) {
|
|
|
|
params := &handler.WriteOptions{
|
|
|
|
Code: http.StatusOK,
|
|
|
|
}
|
|
|
|
for _, o := range opts {
|
|
|
|
o(params)
|
|
|
|
}
|
|
|
|
|
|
|
|
w.ctx.JSON(params.Code, resp)
|
2024-12-29 23:15:44 +00:00
|
|
|
}
|
2024-12-30 23:35:31 +00:00
|
|
|
|
|
|
|
func (w ginWriter) SetCookie(name string, value string, maxAge int, path string, domain string, secure bool, httpOnly bool) {
|
|
|
|
w.ctx.SetCookie(name, value, maxAge, path, domain, secure, httpOnly)
|
|
|
|
}
|