Discover Catalog Per
This commit is contained in:
@@ -1,10 +1,16 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
cx "context"
|
||||
"net/http"
|
||||
"oc-catalog/infrastructure"
|
||||
|
||||
oclib "cloud.o-forge.io/core/oc-lib"
|
||||
w "cloud.o-forge.io/core/oc-lib/models/workflow"
|
||||
tools "cloud.o-forge.io/core/oc-lib/tools"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
"github.com/beego/beego/v2/server/web/context"
|
||||
"golang.org/x/net/websocket"
|
||||
)
|
||||
|
||||
// Operations about compute
|
||||
@@ -55,3 +61,14 @@ func (o *GeneralController) GetAll() {
|
||||
|
||||
o.ServeJSON()
|
||||
}
|
||||
|
||||
func Websocket(ctx cx.Context, user string, r *context.Response, w *http.Request) {
|
||||
websocket.Handler(func(ws *websocket.Conn) {
|
||||
defer ws.Close()
|
||||
for {
|
||||
if msg, ok := <-infrastructure.Singleton.SearchStream[user]; !ok || websocket.Message.Send(ws, msg) != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
}).ServeHTTP(r, w)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user