refactor: move http api to a new transport layer
This commit is contained in:
parent
476c4b056f
commit
0448f66ab2
41 changed files with 822 additions and 390 deletions
|
|
@ -4,20 +4,20 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"git.wzray.com/homelab/hivemind/internal/types"
|
||||
"git.wzray.com/homelab/hivemind/internal/web"
|
||||
)
|
||||
|
||||
func fail(format string, a ...any) []byte {
|
||||
r, _ := json.Marshal(types.Response[string]{
|
||||
r, _ := json.Marshal(web.Response[string]{
|
||||
Ok: false,
|
||||
Err: fmt.Sprintf(format, a...),
|
||||
})
|
||||
return r
|
||||
}
|
||||
|
||||
func ok[T any](data T) ([]byte, error) {
|
||||
return json.Marshal(types.Response[T]{
|
||||
func ok(data []byte) ([]byte, error) {
|
||||
return json.Marshal(web.Response[json.RawMessage]{
|
||||
Ok: true,
|
||||
Data: data,
|
||||
Data: json.RawMessage(data),
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue