aboutsummaryrefslogtreecommitdiffstats
path: root/api/dto/response.go
blob: 43f98bdbb8da891ae2866c125fc94e008951ab6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package dto

import "fmt"

type OkResponse struct {
	Code int         `json:"code"`
	Data interface{} `json:"data,omitempty"`
}

type ErrorResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

func (r *OkResponse) Error() string {
	return fmt.Sprintf("HTTP status %d", r.Code)
}

func (r *ErrorResponse) Error() string {
	return fmt.Sprintf("HTTP status %d: %s", r.Code, r.Message)
}