Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
chore: code clean (#516)
boojack013ded1e04d6
diff --git a/server/acl.go b/server/acl.goindex b653999ca..582343221 100644--- a/server/acl.go+++ b/server/acl.go@@ -105,7 +105,7 @@ func aclMiddleware(s *Server, next echo.HandlerFunc) echo.HandlerFunc {return next(c)}- if common.HasPrefixes(path, "/api/memo", "/api/tag", "/api/shortcut", "/api/memo/stats") && c.Request().Method == http.MethodGet {+ if common.HasPrefixes(path, "/api/memo", "/api/tag", "/api/shortcut") && c.Request().Method == http.MethodGet {if _, err := strconv.Atoi(c.QueryParam("creatorId")); err == nil {return next(c)}diff --git a/server/http_getter.go b/server/http_getter.goindex 65da8053c..a0c40ada9 100644--- a/server/http_getter.go+++ b/server/http_getter.go@@ -11,7 +11,7 @@ import (metric "github.com/usememos/memos/plugin/metrics")-func (s *Server) registerCrawlerPublicRoutes(g *echo.Group) {+func (s *Server) registerGetterPublicRoutes(g *echo.Group) {g.GET("/get/httpmeta", func(c echo.Context) error {ctx := c.Request().Context()urlStr := c.QueryParam("url")@@ -39,6 +39,7 @@ func (s *Server) registerCrawlerPublicRoutes(g *echo.Group) {}return nil})+g.GET("/get/image", func(c echo.Context) error {ctx := c.Request().Context()urlStr := c.QueryParam("url")@@ -51,7 +52,7 @@ func (s *Server) registerCrawlerPublicRoutes(g *echo.Group) {image, err := getter.GetImage(urlStr)if err != nil {- return echo.NewHTTPError(http.StatusNotAcceptable, fmt.Sprintf("Failed to get image url: %s", urlStr)).SetInternal(err)+ return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Failed to get image url: %s", urlStr)).SetInternal(err)}s.Collector.Collect(ctx, &metric.Metric{Name: "getter used",@@ -62,6 +63,7 @@ func (s *Server) registerCrawlerPublicRoutes(g *echo.Group) {c.Response().Writer.WriteHeader(http.StatusOK)c.Response().Writer.Header().Set("Content-Type", image.Mediatype)+ c.Response().Writer.Header().Set(echo.HeaderCacheControl, "max-age=31536000, immutable")if _, err := c.Response().Writer.Write(image.Blob); err != nil {return echo.NewHTTPError(http.StatusInternalServerError, "Failed to write image blob").SetInternal(err)}diff --git a/server/resource.go b/server/resource.goindex b21462faa..b7778edc2 100644--- a/server/resource.go+++ b/server/resource.go@@ -262,11 +262,10 @@ func (s *Server) registerResourcePublicRoutes(g *echo.Group) {c.Response().Writer.WriteHeader(http.StatusOK)c.Response().Writer.Header().Set("Content-Type", resource.Type)- c.Response().Header().Set(echo.HeaderCacheControl, "max-age=31536000, immutable")+ c.Response().Writer.Header().Set(echo.HeaderCacheControl, "max-age=31536000, immutable")if _, err := c.Response().Writer.Write(resource.Blob); err != nil {return echo.NewHTTPError(http.StatusInternalServerError, "Failed to write response").SetInternal(err)}-return nil})}diff --git a/server/server.go b/server/server.goindex 3ca332ef9..243f26adf 100644--- a/server/server.go+++ b/server/server.go@@ -66,7 +66,7 @@ func NewServer(profile *profile.Profile) *Server {publicGroup := e.Group("/o")s.registerResourcePublicRoutes(publicGroup)- s.registerCrawlerPublicRoutes(publicGroup)+ s.registerGetterPublicRoutes(publicGroup)apiGroup := e.Group("/api")apiGroup.Use(func(next echo.HandlerFunc) echo.HandlerFunc {