Initial CPONE middleware implementation
This commit is contained in:
25
internal/http/response.go
Normal file
25
internal/http/response.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"primaya-api/cpone-middleware/internal/repository"
|
||||
)
|
||||
|
||||
type Response struct {
|
||||
Success bool `json:"success"`
|
||||
Message string `json:"message"`
|
||||
Data any `json:"data"`
|
||||
}
|
||||
|
||||
type MappingHargaData struct {
|
||||
PeriodeTarifID string `json:"PeriodeTarifID"`
|
||||
DetailLayanan []repository.TarifLayanan `json:"DetailLayanan"`
|
||||
}
|
||||
|
||||
func WriteJSON(w http.ResponseWriter, statusCode int, payload Response) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(statusCode)
|
||||
_ = json.NewEncoder(w).Encode(payload)
|
||||
}
|
||||
Reference in New Issue
Block a user