2024-01-12 04:13:10 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
2024-01-16 16:42:50 +00:00
|
|
|
"git.lumeweb.com/LumeWeb/portal/api/s5"
|
2024-01-12 04:13:10 +00:00
|
|
|
"git.lumeweb.com/LumeWeb/portal/interfaces"
|
|
|
|
"git.lumeweb.com/LumeWeb/portal/protocols"
|
2024-01-16 16:42:50 +00:00
|
|
|
"go.sia.tech/jape"
|
2024-01-12 04:13:10 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
_ interfaces.API = (*S5API)(nil)
|
|
|
|
)
|
|
|
|
|
|
|
|
type S5API struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewS5() *S5API {
|
|
|
|
return &S5API{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s S5API) Initialize(portal interfaces.Portal, protocol interfaces.Protocol) error {
|
|
|
|
s5protocol := protocol.(*protocols.S5Protocol)
|
2024-01-16 16:42:50 +00:00
|
|
|
s5http := s5.NewHttpHandler(portal)
|
|
|
|
registerProtocolSubdomain(portal, s5protocol.Node().Services().HTTP().GetHttpRouter(getRoutes(s5http)), "s5")
|
2024-01-12 04:13:10 +00:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2024-01-16 16:42:50 +00:00
|
|
|
|
|
|
|
func getRoutes(h *s5.HttpHandler) map[string]jape.Handler {
|
|
|
|
return map[string]jape.Handler{
|
2024-01-16 18:57:33 +00:00
|
|
|
"POST /s5/upload": h.SmallFileUpload,
|
|
|
|
"GET /s5/account/register": h.AccountRegisterChallenge,
|
|
|
|
"POST /s5/account/register": h.AccountRegister,
|
|
|
|
"GET /s5/account/login": h.AccountLoginChallenge,
|
|
|
|
"POST /s5/account/login": h.AccountLogin,
|
2024-01-16 16:42:50 +00:00
|
|
|
}
|
|
|
|
}
|