|
@@ -3,6 +3,8 @@ package main
|
|
|
import (
|
|
|
"flag"
|
|
|
"fmt"
|
|
|
+ "log"
|
|
|
+ "net/http"
|
|
|
|
|
|
"app.yhyue.com/moapp/dataDeduplication/api/internal/config"
|
|
|
"app.yhyue.com/moapp/dataDeduplication/api/internal/handler"
|
|
@@ -23,7 +25,20 @@ func main() {
|
|
|
ctx := svc.NewServiceContext(c)
|
|
|
server := rest.MustNewServer(c.RestConf)
|
|
|
defer server.Stop()
|
|
|
-
|
|
|
+ //追加防止缓存中间件
|
|
|
+ noCacheMiddleware := rest.ToMiddleware(func(next http.Handler) http.Handler {
|
|
|
+
|
|
|
+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
+ log.Println(r.URL,"232")
|
|
|
+ defer func() {
|
|
|
+ w.Header().Set("Pragma", "no-cache")
|
|
|
+ w.Header().Set("Cache-Control", "no-cache")
|
|
|
+ w.Header().Set("Expires", "0")
|
|
|
+ }()
|
|
|
+ next.ServeHTTP(w, r)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ server.Use(noCacheMiddleware)
|
|
|
handler.RegisterHandlers(server, ctx)
|
|
|
|
|
|
fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port)
|