|
@ -2,6 +2,7 @@ package cmd |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
"context" |
|
|
"context" |
|
|
|
|
|
"net/http" |
|
|
"practice_ArticleVote_Go/internal/controller/article" |
|
|
"practice_ArticleVote_Go/internal/controller/article" |
|
|
vr "practice_ArticleVote_Go/internal/controller/vote_record" |
|
|
vr "practice_ArticleVote_Go/internal/controller/vote_record" |
|
|
|
|
|
|
|
@ -17,6 +18,15 @@ var ( |
|
|
Brief: "start http server", |
|
|
Brief: "start http server", |
|
|
Func: func(ctx context.Context, parser *gcmd.Parser) (err error) { |
|
|
Func: func(ctx context.Context, parser *gcmd.Parser) (err error) { |
|
|
s := g.Server() |
|
|
s := g.Server() |
|
|
|
|
|
s.Use(func(r *ghttp.Request) { |
|
|
|
|
|
r.Response.CORSDefault() |
|
|
|
|
|
if r.Method == http.MethodOptions { |
|
|
|
|
|
r.Response.WriteStatus(http.StatusOK) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
r.Middleware.Next() |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
s.Group("/", func(group *ghttp.RouterGroup) { |
|
|
s.Group("/", func(group *ghttp.RouterGroup) { |
|
|
group.Middleware(ghttp.MiddlewareHandlerResponse) |
|
|
group.Middleware(ghttp.MiddlewareHandlerResponse) |
|
|
group.Bind(article.ArticlecController) |
|
|
group.Bind(article.ArticlecController) |
|
|