uplink/plugins/icecast/input/instance.go

51 lines
1.1 KiB
Go
Raw Normal View History

2018-04-10 14:34:41 +00:00
package main
2018-04-10 15:08:40 +00:00
import (
"git.icedream.tech/icedream/uplink/app"
"git.icedream.tech/icedream/uplink/app/servers/http"
"github.com/gin-gonic/gin"
)
2018-04-10 14:34:41 +00:00
type pluginInstance struct {
server *app.Server
}
2018-04-10 15:08:40 +00:00
func (instance *pluginInstance) SetServer(server *httpserver.Server) {
2018-04-10 14:34:41 +00:00
instance.server = server
2018-04-10 15:08:40 +00:00
router := instance.server.Router
router.POST("/:channel", func(ctx *gin.Context) {
channel := server.ChannelManager.Channel(ctx.Param("channel"))
if channel == nil {
ctx.Status(404)
return
}
if user, password, ok := ctx.Request.BasicAuth(); ok {
if !server.Authenticator.VerifyUsernameAndPassword(channel, user, password) {
ctx.Status(401)
return
}
} else {
ctx.Status(401)
return
}
})
router.GET("/:channel", func(ctx *gin.Context) {
channel := server.ChannelManager.Channel(ctx.Param("channel"))
if channel == nil {
ctx.Status(404)
return
}
})
router.GET("/:channel/:stream", func(ctx *gin.Context) {
channel := server.ChannelManager.Channel(ctx.Param("channel"))
if channel == nil {
ctx.Status(404)
return
}
})
2018-04-10 14:34:41 +00:00
}