diff --git a/internal/config/config.go b/internal/config/config.go index 8f846a97d..2c970cff7 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -119,7 +119,7 @@ func (cfg *Config) GetAPIBaseURL() string { if isHTTPS { schema = "https" } - return fmt.Sprintf("%s://%s:%d%s", schema, cfg.Host, cfg.Port, "/handlers/v1/") + return fmt.Sprintf("%s://%s:%d%s", schema, cfg.Host, cfg.Port, "/api/v1/") } func loadEnvs() { diff --git a/service/frontend/middleware/global.go b/service/frontend/middleware/global.go index 2dfa732f6..09a9b9cb9 100644 --- a/service/frontend/middleware/global.go +++ b/service/frontend/middleware/global.go @@ -46,7 +46,7 @@ func Setup(opts *Options) { func prefixChecker(next http.Handler) http.Handler { return http.HandlerFunc( func(w http.ResponseWriter, r *http.Request) { - if strings.HasPrefix(r.URL.Path, "/handlers") { + if strings.HasPrefix(r.URL.Path, "/api") { next.ServeHTTP(w, r) } else { defaultHandler.ServeHTTP(w, r) diff --git a/service/frontend/restapi/doc.go b/service/frontend/restapi/doc.go index 0e30d3324..ee2c1619a 100644 --- a/service/frontend/restapi/doc.go +++ b/service/frontend/restapi/doc.go @@ -5,7 +5,7 @@ // Schemes: // http // Host: localhost:8080 -// BasePath: /handlers/v1 +// BasePath: /api/v1 // Version: 0.0.1 // // Consumes: diff --git a/service/frontend/restapi/embedded_spec.go b/service/frontend/restapi/embedded_spec.go index 0139792b4..d38632908 100644 --- a/service/frontend/restapi/embedded_spec.go +++ b/service/frontend/restapi/embedded_spec.go @@ -33,7 +33,7 @@ func init() { "version": "0.0.1" }, "host": "localhost:8080", - "basePath": "/handlers/v1", + "basePath": "/api/v1", "paths": { "/dags": { "get": { @@ -1002,7 +1002,7 @@ func init() { "version": "0.0.1" }, "host": "localhost:8080", - "basePath": "/handlers/v1", + "basePath": "/api/v1", "paths": { "/dags": { "get": { diff --git a/service/frontend/restapi/operations/create_dag_urlbuilder.go b/service/frontend/restapi/operations/create_dag_urlbuilder.go index 79a6700ad..fce181d8c 100644 --- a/service/frontend/restapi/operations/create_dag_urlbuilder.go +++ b/service/frontend/restapi/operations/create_dag_urlbuilder.go @@ -39,7 +39,7 @@ func (o *CreateDagURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/handlers/v1" + _basePath = "/api/v1" } _result.Path = golangswaggerpaths.Join(_basePath, _path) diff --git a/service/frontend/restapi/operations/dagu_api.go b/service/frontend/restapi/operations/dagu_api.go index 36173ad17..1505d438a 100644 --- a/service/frontend/restapi/operations/dagu_api.go +++ b/service/frontend/restapi/operations/dagu_api.go @@ -318,7 +318,7 @@ func (o *DaguAPI) initHandlerCache() { } // Serve creates a http handler to serve the API over HTTP -// can be used directly in http.ListenAndServe(":8000", handlers.Serve(nil)) +// can be used directly in http.ListenAndServe(":8000", api.Serve(nil)) func (o *DaguAPI) Serve(builder middleware.Builder) http.Handler { o.Init() diff --git a/service/frontend/restapi/operations/delete_dag_urlbuilder.go b/service/frontend/restapi/operations/delete_dag_urlbuilder.go index 62529685a..8db5b2d7b 100644 --- a/service/frontend/restapi/operations/delete_dag_urlbuilder.go +++ b/service/frontend/restapi/operations/delete_dag_urlbuilder.go @@ -51,7 +51,7 @@ func (o *DeleteDagURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/handlers/v1" + _basePath = "/api/v1" } _result.Path = golangswaggerpaths.Join(_basePath, _path) diff --git a/service/frontend/restapi/operations/get_dag_details_urlbuilder.go b/service/frontend/restapi/operations/get_dag_details_urlbuilder.go index 9a484fafd..f433759ce 100644 --- a/service/frontend/restapi/operations/get_dag_details_urlbuilder.go +++ b/service/frontend/restapi/operations/get_dag_details_urlbuilder.go @@ -55,7 +55,7 @@ func (o *GetDagDetailsURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/handlers/v1" + _basePath = "/api/v1" } _result.Path = golangswaggerpaths.Join(_basePath, _path) diff --git a/service/frontend/restapi/operations/list_dags_urlbuilder.go b/service/frontend/restapi/operations/list_dags_urlbuilder.go index fd92f75de..82c366cdb 100644 --- a/service/frontend/restapi/operations/list_dags_urlbuilder.go +++ b/service/frontend/restapi/operations/list_dags_urlbuilder.go @@ -39,7 +39,7 @@ func (o *ListDagsURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/handlers/v1" + _basePath = "/api/v1" } _result.Path = golangswaggerpaths.Join(_basePath, _path) diff --git a/service/frontend/restapi/operations/post_dag_action_urlbuilder.go b/service/frontend/restapi/operations/post_dag_action_urlbuilder.go index bc8ac0080..cf735ebf9 100644 --- a/service/frontend/restapi/operations/post_dag_action_urlbuilder.go +++ b/service/frontend/restapi/operations/post_dag_action_urlbuilder.go @@ -51,7 +51,7 @@ func (o *PostDagActionURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/handlers/v1" + _basePath = "/api/v1" } _result.Path = golangswaggerpaths.Join(_basePath, _path) diff --git a/service/frontend/restapi/operations/search_dags_urlbuilder.go b/service/frontend/restapi/operations/search_dags_urlbuilder.go index c7d3dfe1a..f09b6084a 100644 --- a/service/frontend/restapi/operations/search_dags_urlbuilder.go +++ b/service/frontend/restapi/operations/search_dags_urlbuilder.go @@ -43,7 +43,7 @@ func (o *SearchDagsURL) Build() (*url.URL, error) { _basePath := o._basePath if _basePath == "" { - _basePath = "/handlers/v1" + _basePath = "/api/v1" } _result.Path = golangswaggerpaths.Join(_basePath, _path) diff --git a/service/frontend/restapi/server.go b/service/frontend/restapi/server.go index 98983bba9..4f81e5951 100644 --- a/service/frontend/restapi/server.go +++ b/service/frontend/restapi/server.go @@ -41,7 +41,7 @@ func init() { } } -// NewServer creates a new handlers dagu server but does not configure it +// NewServer creates a new api dagu server but does not configure it func NewServer(api *operations.DaguAPI) *Server { s := new(Server) @@ -149,7 +149,7 @@ func (s *Server) hasScheme(scheme string) bool { return false } -// Serve the handlers +// Serve the api func (s *Server) Serve() (err error) { if !s.hasListeners { if err = s.Listen(); err != nil { @@ -160,7 +160,7 @@ func (s *Server) Serve() (err error) { // set default handler, if none is set if s.handler == nil { if s.api == nil { - return errors.New("can't create the default handler, as no handlers is set") + return errors.New("can't create the default handler, as no api is set") } s.SetHandler(s.api.Serve(nil)) @@ -405,7 +405,7 @@ func (s *Server) Shutdown() error { } func (s *Server) handleShutdown(wg *sync.WaitGroup, serversPtr *[]*http.Server) { - // wg.Done must occur last, after s.handlers.ServerShutdown() + // wg.Done must occur last, after s.api.ServerShutdown() // (to preserve old behaviour) defer wg.Done()