From 4b81e8820dd05c4073bf41b50d3aafb2919136e5 Mon Sep 17 00:00:00 2001 From: Heinrich 'Henrik' Langos Date: Sun, 15 Jan 2023 12:18:01 +0100 Subject: refactor: Extract simple case that renders the upload form page --- app/app.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'app') diff --git a/app/app.go b/app/app.go index 535ec21..5fc17e3 100644 --- a/app/app.go +++ b/app/app.go @@ -222,17 +222,22 @@ func filenameWithoutExtension(path string) (stem string) { return basename[0:len(basename)-len(filepath.Ext(basename))] } +// Render the upload page where clients can select and upload their video files +func (a *App) renderUploadPage(respWriter http.ResponseWriter) { + ctx := &struct { + Config *Config + Playing *media.Video + }{ + Config: a.Config, + Playing: &media.Video{ID: ""}, + } + a.render("upload", respWriter, ctx) +} + // HTTP handler for /upload func (a *App) uploadHandler(respWriter http.ResponseWriter, request *http.Request) { if request.Method == "GET" { - ctx := &struct { - Config *Config - Playing *media.Video - }{ - Config: a.Config, - Playing: &media.Video{ID: ""}, - } - a.render("upload", respWriter, ctx) + a.renderUploadPage(respWriter) } else if request.Method == "POST" { request.ParseMultipartForm(a.Config.Server.MaxUploadSize) -- cgit v1.2.3