forked from jriou/coller
feat: serve clients binaries from a local directory
Fixes #44. Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
b0c0162b06
commit
ab6b03a6d4
4 changed files with 13 additions and 5 deletions
|
@ -232,8 +232,9 @@ func (h *GetProtectedNoteHandler) ServeHTTP(w http.ResponseWriter, r *http.Reque
|
|||
}
|
||||
|
||||
type ClientHandler struct {
|
||||
logger *slog.Logger
|
||||
version string
|
||||
logger *slog.Logger
|
||||
version string
|
||||
directory string
|
||||
}
|
||||
|
||||
func (h *ClientHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -253,5 +254,9 @@ func (h *ClientHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
version = "latest"
|
||||
}
|
||||
|
||||
http.Redirect(w, r, fmt.Sprintf("https://git.riou.xyz/jriou/coller/releases/download/%s/%s-%s-%s", version, clientName, os, arch), http.StatusMovedPermanently)
|
||||
if h.directory != "" {
|
||||
http.ServeFile(w, r, h.directory+"/"+fmt.Sprintf("%s-%s-%s", clientName, os, arch))
|
||||
} else {
|
||||
http.Redirect(w, r, fmt.Sprintf("https://git.riou.xyz/jriou/coller/releases/download/%s/%s-%s-%s", version, clientName, os, arch), http.StatusMovedPermanently)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue