Single binary build (#10)

Single binary build
Use go rice for embedding the static files and templates to the binary file
This commit is contained in:
Khanh Ngo 2020-05-21 15:51:24 +07:00 committed by GitHub
parent b741a915ae
commit 9a27cc366f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 169 additions and 34 deletions

View file

@ -3,6 +3,7 @@ package handler
import (
"encoding/json"
"fmt"
rice "github.com/GeertJohan/go.rice"
"net/http"
"strings"
"time"
@ -429,7 +430,7 @@ func SuggestIPAllocation() echo.HandlerFunc {
}
// ApplyServerConfig handler to write config file and restart Wireguard server
func ApplyServerConfig() echo.HandlerFunc {
func ApplyServerConfig(tmplBox *rice.Box) echo.HandlerFunc {
return func(c echo.Context) error {
// access validation
validSession(c)
@ -453,7 +454,7 @@ func ApplyServerConfig() echo.HandlerFunc {
}
// Write config file
err = util.WriteWireGuardServerConfig(server, clients, settings)
err = util.WriteWireGuardServerConfig(tmplBox, server, clients, settings)
if err != nil {
log.Error("Cannot apply server config: ", err)
return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{false, fmt.Sprintf("Cannot apply server config: %v", err)})