Reduce handler request boilerplate
- Add session.Attach to reuse per-request sessions across middleware and ghome handlers - Make Session finalize/abort paths idempotent to avoid duplicate commit or rollback work - Move request_data parsing helper to internal/utils - Expand ParseRequestData usage across api, download, unit, live, multiunit, and subscenario handlers - Extract download package metadata into internal/handler/download/types.go - Return explicit errors from selected session lookup helpers and update callers - Make api action handlers return errors directly instead of calling ss.CheckErr in nested layers Signed-off-by: Sean Du <do4suki@gmail.com>
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package unit
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"honoka-chan/internal/middleware"
|
||||
unitmodel "honoka-chan/internal/model/unit"
|
||||
usermodel "honoka-chan/internal/model/user"
|
||||
@@ -9,6 +8,7 @@ import (
|
||||
unitapischema "honoka-chan/internal/schema/api/unit"
|
||||
unitschema "honoka-chan/internal/schema/unit"
|
||||
"honoka-chan/internal/session"
|
||||
honokautils "honoka-chan/internal/utils"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -19,7 +19,7 @@ func deck(ctx *gin.Context) {
|
||||
defer ss.Finalize()
|
||||
|
||||
deckReq := unitschema.DeckReq{}
|
||||
err := json.Unmarshal([]byte(ctx.MustGet("request_data").(string)), &deckReq)
|
||||
err := honokautils.ParseRequestData(ctx, &deckReq)
|
||||
if ss.CheckErr(err) {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user