aboutsummaryrefslogtreecommitdiff
path: root/http_server.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2023-11-09 12:58:54 +0700
committerShulhan <ms@kilabit.info>2023-11-09 12:58:54 +0700
commitcf6d0e5bb0baf5acbc70f8084d087e3a41b5452e (patch)
treeb638fbc784f75c9a2a902374b5a6373e8bb577a2 /http_server.go
parentfe14373978ab611cb7757df9f3ade411d9f716b0 (diff)
downloadawwan-cf6d0e5bb0baf5acbc70f8084d087e3a41b5452e.tar.xz
all: on file save, make sure file end with line-feed
On some application, like haproxy configuration, line-feed (LF or "\n") are required, otherwise the application would not start.
Diffstat (limited to 'http_server.go')
-rw-r--r--http_server.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/http_server.go b/http_server.go
index 03e0aad..a618058 100644
--- a/http_server.go
+++ b/http_server.go
@@ -380,6 +380,12 @@ func (httpd *httpServer) awwanApiFsPut(epr *libhttp.EndpointRequest) (rawBody []
return nil, res
}
+ // Make sure that the file end with LF.
+ var lenContent = len(req.Content)
+ if lenContent != 0 && req.Content[lenContent-1] != '\n' {
+ req.Content = append(req.Content, '\n')
+ }
+
err = node.Save(req.Content)
if err != nil {
res.Message = fmt.Sprintf("%s: %s", logp, err)