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
17
internal/transport/node/client.go
Normal file
17
internal/transport/node/client.go
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
package node
|
||||
|
||||
import (
|
||||
"git.wzray.com/homelab/hivemind/internal/transport"
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
caller transport.Caller
|
||||
}
|
||||
|
||||
func New(caller transport.Caller) *Client {
|
||||
return &Client{caller: caller}
|
||||
}
|
||||
|
||||
func (c *Client) Healthcheck(endpoint string) (string, error) {
|
||||
return healthcheckRoute.CallNoInput(c.caller, endpoint)
|
||||
}
|
||||
13
internal/transport/node/handlers.go
Normal file
13
internal/transport/node/handlers.go
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
package node
|
||||
|
||||
import (
|
||||
"git.wzray.com/homelab/hivemind/internal/transport"
|
||||
)
|
||||
|
||||
type NodeHandlers interface {
|
||||
Healthcheck() (string, error)
|
||||
}
|
||||
|
||||
func Register(registrator transport.Registrator, h NodeHandlers) {
|
||||
healthcheckRoute.Register(registrator, transport.WithoutInput(h.Healthcheck))
|
||||
}
|
||||
9
internal/transport/node/routes.go
Normal file
9
internal/transport/node/routes.go
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
package node
|
||||
|
||||
import (
|
||||
"git.wzray.com/homelab/hivemind/internal/transport"
|
||||
)
|
||||
|
||||
var (
|
||||
healthcheckRoute = transport.NewRoute[struct{}, string]("/node/healthcheck")
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue