blog/internal/controller/FileController.go

31 lines
656 B
Go

package controller
import (
"blog/internal/service"
"github.com/kataras/iris/v12"
"github.com/kataras/iris/v12/mvc"
"github.com/kataras/iris/v12/sessions"
)
type FileController struct {
Ctx iris.Context
Session *sessions.Session
}
func (ctrl *FileController) ViewFile() {
relId := ctrl.Ctx.Params().Get("id")
bytes := service.FileService.GetFile(relId)
ctrl.Ctx.Write(bytes)
}
func (ctrl *FileController) BeforeActivation(activation mvc.BeforeActivation) {
// log.Println("before")
activation.Handle("GET", "{id}", "ViewFile")
}
func (ctrl *FileController) AfterActivation(activation mvc.AfterActivation) {
// log.Println("after")
}