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
22
internal/transport/registrator.go
Normal file
22
internal/transport/registrator.go
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
package transport
|
||||
|
||||
import (
|
||||
"git.wzray.com/homelab/hivemind/internal/transport/codec"
|
||||
)
|
||||
|
||||
type Handler struct {
|
||||
path string
|
||||
handler func(codec.Codec, []byte) ([]byte, error)
|
||||
}
|
||||
|
||||
func (h Handler) Path() string {
|
||||
return h.path
|
||||
}
|
||||
|
||||
func (h Handler) Handle(c codec.Codec, v []byte) ([]byte, error) {
|
||||
return h.handler(c, v)
|
||||
}
|
||||
|
||||
type Registrator interface {
|
||||
Register(endpoint Handler)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue