static_javascript.go 832 B

1234567891011121314151617181920212223242526272829
  1. // Copyright 2018 Frédéric Guillot. All rights reserved.
  2. // Use of this source code is governed by the Apache 2.0
  3. // license that can be found in the LICENSE file.
  4. package ui
  5. import (
  6. "net/http"
  7. "time"
  8. "github.com/miniflux/miniflux/http/request"
  9. "github.com/miniflux/miniflux/http/response"
  10. "github.com/miniflux/miniflux/http/response/html"
  11. "github.com/miniflux/miniflux/ui/static"
  12. )
  13. // Javascript renders application client side code.
  14. func (c *Controller) Javascript(w http.ResponseWriter, r *http.Request) {
  15. filename := request.Param(r, "name", "app")
  16. if _, found := static.Javascripts[filename]; !found {
  17. html.NotFound(w)
  18. return
  19. }
  20. body := static.Javascripts[filename]
  21. etag := static.JavascriptsChecksums[filename]
  22. response.Cache(w, r, "text/javascript; charset=utf-8", etag, []byte(body), 48*time.Hour)
  23. }