-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
강보원
authored and
강보원
committed
Jan 20, 2025
1 parent
40e280a
commit 263e7ed
Showing
2 changed files
with
18 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// internal/handler/korcen.go | ||
|
||
package handler | ||
|
||
import ( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,23 @@ | ||
// internal/handler/respond.go | ||
|
||
package handler | ||
|
||
import "github.com/gin-gonic/gin" | ||
import ( | ||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
type ResponseType int | ||
|
||
const ( | ||
JSON ResponseType = iota | ||
XML | ||
) | ||
|
||
func respond(c *gin.Context, status int, isXML bool, payload interface{}) { | ||
if isXML { | ||
func respond(c *gin.Context, status int, responseType ResponseType, payload interface{}) { | ||
switch responseType { | ||
case XML: | ||
c.XML(status, payload) | ||
} else { | ||
default: | ||
c.JSON(status, payload) | ||
} | ||
} |