set /raw/ to cache
This commit is contained in:
@@ -2,12 +2,13 @@ package server
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"gitea.inhome.blapointe.com/local/gziphttp"
|
||||
"gitea.inhome.blapointe.com/local/notes-server/config"
|
||||
"gitea.inhome.blapointe.com/local/router"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"gitea.inhome.blapointe.com/local/gziphttp"
|
||||
"gitea.inhome.blapointe.com/local/notes-server/config"
|
||||
"gitea.inhome.blapointe.com/local/router"
|
||||
)
|
||||
|
||||
func (s *Server) Routes() error {
|
||||
@@ -19,7 +20,7 @@ func (s *Server) Routes() error {
|
||||
handler: s.root,
|
||||
},
|
||||
fmt.Sprintf("raw/%s%s", wildcard, wildcard): {
|
||||
handler: s.gzip(s.authenticate(s.raw)),
|
||||
handler: s.gzip(s.authenticate(s.cached(s.raw))),
|
||||
},
|
||||
fmt.Sprintf("notes/%s%s", wildcard, wildcard): {
|
||||
handler: s.gzip(s.authenticate(s.notes)),
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"gitea.inhome.blapointe.com/local/notes-server/config"
|
||||
"gitea.inhome.blapointe.com/local/notes-server/notes"
|
||||
"gitea.inhome.blapointe.com/local/oauth2/oauth2client"
|
||||
"gitea.inhome.blapointe.com/local/router"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
@@ -21,6 +22,13 @@ func New() *Server {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) cached(foo http.HandlerFunc) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Cache-Control", "private, max-age=7776000")
|
||||
foo(w, r)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) authenticate(foo http.HandlerFunc) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
if config.OAuthServer != "" {
|
||||
|
||||
Reference in New Issue
Block a user