Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
563eb7bb61 | ||
|
|
b7f13bf33d | ||
|
|
d73cbe9e0c |
@@ -1,8 +1,11 @@
|
||||
FROM frolvlad/alpine-glibc:alpine-3.9_glibc-2.29
|
||||
RUN apk update && apk add --no-cache ca-certificates git
|
||||
|
||||
FROM golang:1.13-alpine as certs
|
||||
RUN apk update && apk add --no-cache ca-certificates
|
||||
|
||||
FROM busybox:glibc
|
||||
RUN mkdir -p /var/log
|
||||
WORKDIR /main
|
||||
COPY --from=certs /etc/ssl/certs /etc/ssl/certs
|
||||
|
||||
COPY . .
|
||||
|
||||
@@ -10,3 +13,4 @@ ENV GOPATH=""
|
||||
ENV MNT="/mnt/"
|
||||
ENTRYPOINT ["/main/exec-notes-server"]
|
||||
CMD []
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ func editFile(p filetree.Path) string {
|
||||
return fmt.Sprintf(`
|
||||
<form action="/submit/%s" method="post" style="width:100%%; height: 90%%">
|
||||
<table style="width:100%%; height: 90%%">
|
||||
<textarea name="content" style="width:100%%; min-height:90%%">%s</textarea>
|
||||
<textarea name="content" style="width:100%%; min-height:90%%; cursor:crosshair;">%s</textarea>
|
||||
</table>
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
|
||||
@@ -2,8 +2,10 @@ package server
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"local/gziphttp"
|
||||
"local/router"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func (s *Server) Routes() error {
|
||||
@@ -18,27 +20,27 @@ func (s *Server) Routes() error {
|
||||
},
|
||||
{
|
||||
path: fmt.Sprintf("notes/%s%s", wildcard, wildcard),
|
||||
handler: s.authenticate(s.notes),
|
||||
handler: s.gzip(s.authenticate(s.notes)),
|
||||
},
|
||||
{
|
||||
path: fmt.Sprintf("edit/%s%s", wildcard, wildcard),
|
||||
handler: s.authenticate(s.edit),
|
||||
handler: s.gzip(s.authenticate(s.edit)),
|
||||
},
|
||||
{
|
||||
path: fmt.Sprintf("delete/%s%s", wildcard, wildcard),
|
||||
handler: s.authenticate(s.delete),
|
||||
handler: s.gzip(s.authenticate(s.delete)),
|
||||
},
|
||||
{
|
||||
path: fmt.Sprintf("submit/%s%s", wildcard, wildcard),
|
||||
handler: s.authenticate(s.submit),
|
||||
handler: s.gzip(s.authenticate(s.submit)),
|
||||
},
|
||||
{
|
||||
path: fmt.Sprintf("create/%s%s", wildcard, wildcard),
|
||||
handler: s.authenticate(s.create),
|
||||
handler: s.gzip(s.authenticate(s.create)),
|
||||
},
|
||||
{
|
||||
path: fmt.Sprintf("search"),
|
||||
handler: s.authenticate(s.search),
|
||||
handler: s.gzip(s.authenticate(s.search)),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -54,3 +56,17 @@ func (s *Server) root(w http.ResponseWriter, r *http.Request) {
|
||||
r.URL.Path = "/notes"
|
||||
http.Redirect(w, r, r.URL.String(), http.StatusPermanentRedirect)
|
||||
}
|
||||
|
||||
func (s *Server) gzip(h http.HandlerFunc) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
if gziphttp.Can(r) {
|
||||
gz := gziphttp.New(w)
|
||||
defer gz.Close()
|
||||
w = gz
|
||||
}
|
||||
if filepath.Ext(r.URL.Path) == ".css" {
|
||||
w.Header().Set("Content-Type", "text/css; charset=utf-8")
|
||||
}
|
||||
h(w, r)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user