Skip to content

Commit

Permalink
final routing fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirari04 committed Jan 18, 2024
1 parent 4e944e3 commit 6554dda
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 34 deletions.
4 changes: 2 additions & 2 deletions controllers/DownloadVideoController.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (

func DownloadVideoController(c echo.Context) error {
type Request struct {
UUID string `validate:"required,uuid_rfc4122"`
QUALITY string `validate:"required,min=1,max=10"`
UUID string `validate:"required,uuid_rfc4122" param:"UUID"`
QUALITY string `validate:"required,min=1,max=10" param:"QUALITY"`
}
var requestValidation Request
if status, err := helpers.Validate(c, &requestValidation); err != nil {
Expand Down
6 changes: 3 additions & 3 deletions controllers/GetSubtitleDataController.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (

func GetSubtitleData(c echo.Context) error {
type Request struct {
UUID string `validate:"required,uuid_rfc4122"`
SUBUUID string `validate:"required,uuid_rfc4122"`
FILE string `validate:"required"`
UUID string `validate:"required,uuid_rfc4122" param:"UUID"`
SUBUUID string `validate:"required,uuid_rfc4122" param:"SUBUUID"`
FILE string `validate:"required" param:"FILE"`
}
var requestValidation Request
if status, err := helpers.Validate(c, &requestValidation); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions controllers/GetThumbnailDataController.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (

func GetThumbnailData(c echo.Context) error {
type Request struct {
UUID string `validate:"required,uuid_rfc4122"`
FILE string `validate:"required"`
UUID string `validate:"required,uuid_rfc4122" param:"UUID"`
FILE string `validate:"required" param:"FILE"`
}
var requestValidation Request
if status, err := helpers.Validate(c, &requestValidation); err != nil {
Expand Down
6 changes: 3 additions & 3 deletions controllers/GetVideoDataController.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (

func GetVideoData(c echo.Context) error {
type Request struct {
UUID string `validate:"required,uuid_rfc4122"`
QUALITY string `validate:"required,min=1,max=10"`
FILE string `validate:"required"`
UUID string `validate:"required,uuid_rfc4122" param:"UUID"`
QUALITY string `validate:"required,min=1,max=10" param:"QUALITY"`
FILE string `validate:"required" param:"FILE"`
}
var requestValidation Request
if status, err := helpers.Validate(c, &requestValidation); err != nil {
Expand Down
6 changes: 3 additions & 3 deletions controllers/PlayerController.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
func PlayerController(c echo.Context) error {
// parse & validate request
type Request struct {
UUID string `validate:"required,uuid_rfc4122"`
UUID string `validate:"required,uuid_rfc4122" param:"UUID"`
}
var requestValidation Request
if status, err := helpers.Validate(c, &requestValidation); err != nil {
Expand All @@ -38,7 +38,7 @@ func PlayerController(c echo.Context) error {
UUID: requestValidation.UUID,
}).
First(&dbLink); res.Error != nil {
return c.Render(http.StatusNotFound, "404", echo.Map{})
return c.Render(http.StatusNotFound, "404.html", echo.Map{})
}

// generate jwt token that allows the user to access the stream
Expand Down Expand Up @@ -130,7 +130,7 @@ func PlayerController(c echo.Context) error {
// Domain: config.ENV.CookieDomain,
// HTTPOnly: true,
// })
return c.Render(http.StatusOK, "player", echo.Map{
return c.Render(http.StatusOK, "player.html", echo.Map{
"Title": fmt.Sprintf("%s - %s", config.ENV.AppName, dbLink.Name),
"Description": fmt.Sprintf("Watch %s on %s", dbLink.Name, config.ENV.AppName),
"Thumbnail": fmt.Sprintf("%s/%s/image/thumb/%s", config.ENV.FolderVideoQualitysPub, dbLink.UUID, dbLink.File.Thumbnail),
Expand Down
2 changes: 1 addition & 1 deletion controllers/ViewExampleUploadController.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func ViewExampleUpload(c echo.Context) error {
return c.Render(http.StatusOK, "examples/upload", echo.Map{
return c.Render(http.StatusOK, "examples/upload.html", echo.Map{
"AppName": config.ENV.AppName,
})
}
4 changes: 2 additions & 2 deletions controllers/ViewIndexController.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import (
func ViewIndex(c echo.Context) error {
var link models.Link
if res := inits.DB.First(&link); res.Error != nil {
return c.Render(http.StatusOK, "index", echo.Map{
return c.Render(http.StatusOK, "index.html", echo.Map{
"ExampleVideo": fmt.Sprintf("/%v", "notfound"),
"AppName": config.ENV.AppName,
"ProjectDocumentation": config.ENV.ProjectDocumentation,
"ProjectDownload": config.ENV.ProjectDownload,
})
}
return c.Render(http.StatusOK, "index", echo.Map{
return c.Render(http.StatusOK, "index.html", echo.Map{
"ExampleVideo": fmt.Sprintf("/%v", link.UUID),
"AppName": config.ENV.AppName,
"ProjectDocumentation": config.ENV.ProjectDocumentation,
Expand Down
4 changes: 2 additions & 2 deletions inits/Server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package inits

import (
"ch/kirari04/videocms/config"
"html/template"
"io"
"log"
"net"
"net/http"
"os"
"strings"
"text/template"

"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
Expand All @@ -28,7 +28,7 @@ func (t *Template) Render(w io.Writer, name string, data interface{}, c echo.Con

func Server() {
htmlTemplate := &Template{
templates: template.Must(template.ParseGlob("./views/*.html")),
templates: template.Must(template.ParseGlob("views/*.html")),
}
trustedProxies := []string{}
if *config.ENV.CloudflareEnabled {
Expand Down
6 changes: 3 additions & 3 deletions models/Audio.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ func (c *Audio) Save(DB *gorm.DB) *gorm.DB {
}

type AudioGetValidation struct {
UUID string `validate:"required,uuid_rfc4122"`
AUDIOUUID string `validate:"required,uuid_rfc4122"`
FILE string `validate:"required"`
UUID string `validate:"required,uuid_rfc4122" param:"UUID"`
AUDIOUUID string `validate:"required,uuid_rfc4122" param:"AUDIOUUID"`
FILE string `validate:"required" param:"FILE"`
}

type AvailableAudio struct {
Expand Down
2 changes: 1 addition & 1 deletion models/Folder.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type FolderCreateValidation struct {
}

type FolderListValidation struct {
ParentFolderID uint `validate:"number"`
ParentFolderID uint `validate:"number" query:"ParentFolderID"`
}

type FolderDeleteValidation struct {
Expand Down
12 changes: 6 additions & 6 deletions models/Link.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ type Link struct {
}

type LinkListValidation struct {
ParentFolderID uint `validate:"number"`
ParentFolderID uint `validate:"number" query:"ParentFolderID"`
}

type LinkDeleteValidation struct {
LinkID uint `validate:"required,number"`
LinkID uint `validate:"required,number" form:"LinkID"`
}

type LinkUpdateValidation struct {
LinkID uint `validate:"required,number"`
Name string `validate:"required,min=1,max=120"`
ParentFolderID uint `validate:"number"`
LinkID uint `validate:"required,number" form:"LinkID"`
Name string `validate:"required,min=1,max=120" form:"Name"`
ParentFolderID uint `validate:"number" form:"ParentFolderID"`
}

type LinksDeleteValidation struct {
LinkIDs []LinkDeleteValidation `validate:"required"`
}

type LinkGetValidation struct {
LinkID uint `validate:"required,number"`
LinkID uint `validate:"required,number" query:"LinkID"`
}
4 changes: 2 additions & 2 deletions models/User.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ type User struct {
}

type UserLoginValidation struct {
Username string `validate:"required,min=3,max=32"`
Password string `validate:"required,min=8,max=250"`
Username string `validate:"required,min=3,max=32" form:"username"`
Password string `validate:"required,min=8,max=250" form:"password"`
}

type UserRegisterValidation struct {
Expand Down
2 changes: 1 addition & 1 deletion models/WebPage.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ type WebPageDeleteValidation struct {
}

type WebPageGetValidation struct {
Path string `validate:"required,dirpath,min=2,max=50"`
Path string `validate:"required,dirpath,min=2,max=50" query:"Path"`
}
6 changes: 3 additions & 3 deletions routes/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import (
)

func Web() {
inits.App.Static("/", "./public")
inits.App.Static("/", "public/")

inits.App.GET("/:UUID", controllers.PlayerController)
inits.App.GET("/v/:UUID", controllers.PlayerController)

videoData := inits.App.Group(config.ENV.FolderVideoQualitysPub)
videoData.GET("/:UUID/stream/muted/master.m3u8", controllers.GetM3u8Data, middlewares.JwtStream())
videoData.GET("/:UUID/image/thumb/:FILE", controllers.GetThumbnailData, middlewares.JwtStream())
videoData.GET("/:UUID/image/thumb/:FILE", controllers.GetThumbnailData)
videoData.GET("/:UUID/:SUBUUID/subtitle/:FILE", controllers.GetSubtitleData, middlewares.JwtStream())
videoData.GET("/:UUID/:AUDIOUUID/stream/master.m3u8", controllers.GetM3u8Data, middlewares.JwtStream())
videoData.GET("/:UUID/:QUALITY/download/video.mkv", controllers.DownloadVideoController, middlewares.JwtStream())
Expand Down

0 comments on commit 6554dda

Please sign in to comment.