mirror of
https://github.com/mudler/LocalAI.git
synced 2025-02-10 12:51:14 +00:00
setup ws upgrade
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
parent
e1b1b2848e
commit
e56d437f7c
@ -90,6 +90,15 @@ func API(application *application.Application) (*fiber.App, error) {
|
|||||||
|
|
||||||
router.Use(middleware.StripPathPrefix())
|
router.Use(middleware.StripPathPrefix())
|
||||||
|
|
||||||
|
router.Use(func(c *fiber.Ctx) error {
|
||||||
|
if websocket.IsWebSocketUpgrade(c) {
|
||||||
|
// Returns true if the client requested upgrade to the WebSocket protocol
|
||||||
|
return c.Next()
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
router.Hooks().OnListen(func(listenData fiber.ListenData) error {
|
router.Hooks().OnListen(func(listenData fiber.ListenData) error {
|
||||||
scheme := "http"
|
scheme := "http"
|
||||||
if listenData.TLS {
|
if listenData.TLS {
|
||||||
@ -182,26 +191,6 @@ func API(application *application.Application) (*fiber.App, error) {
|
|||||||
Browse: true,
|
Browse: true,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
app.Use(func(c *fiber.Ctx) error {
|
|
||||||
if websocket.IsWebSocketUpgrade(c) {
|
|
||||||
// Returns true if the client requested upgrade to the WebSocket protocol
|
|
||||||
c.Next()
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
|
|
||||||
// app.Use("/v1/realtime", func(c *fiber.Ctx) error {
|
|
||||||
// fmt.Println("Hit upgrade from http")
|
|
||||||
// // IsWebSocketUpgrade returns true if the client
|
|
||||||
// // requested upgrade to the WebSocket protocol.
|
|
||||||
// if websocket.IsWebSocketUpgrade(c) {
|
|
||||||
// c.Locals("allowed", true)
|
|
||||||
// return c.Next()
|
|
||||||
// }
|
|
||||||
// return fiber.ErrUpgradeRequired
|
|
||||||
// })
|
|
||||||
|
|
||||||
// Define a custom 404 handler
|
// Define a custom 404 handler
|
||||||
// Note: keep this at the bottom!
|
// Note: keep this at the bottom!
|
||||||
router.Use(notFoundHandler)
|
router.Use(notFoundHandler)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user