From 0eee615aea15de32805c3914c233ac7345721578 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sun, 7 Oct 2018 11:40:35 +0200 Subject: [PATCH] rename 'internal/api' to 'internal/apidef' (api definition) --- internal/{api => apidef}/controller.go | 2 +- internal/{api => apidef}/method.go | 2 +- internal/{api => apidef}/types.go | 2 +- server.go | 12 ++++++------ util.go | 10 +++++----- 5 files changed, 14 insertions(+), 14 deletions(-) rename internal/{api => apidef}/controller.go (99%) rename internal/{api => apidef}/method.go (97%) rename internal/{api => apidef}/types.go (98%) diff --git a/internal/api/controller.go b/internal/apidef/controller.go similarity index 99% rename from internal/api/controller.go rename to internal/apidef/controller.go index ecc3c7f..ed606da 100644 --- a/internal/api/controller.go +++ b/internal/apidef/controller.go @@ -1,4 +1,4 @@ -package api +package apidef import ( "encoding/json" diff --git a/internal/api/method.go b/internal/apidef/method.go similarity index 97% rename from internal/api/method.go rename to internal/apidef/method.go index e4c6099..e400d75 100644 --- a/internal/api/method.go +++ b/internal/apidef/method.go @@ -1,4 +1,4 @@ -package api +package apidef import ( "git.xdrm.io/go/aicra/middleware" diff --git a/internal/api/types.go b/internal/apidef/types.go similarity index 98% rename from internal/api/types.go rename to internal/apidef/types.go index 876ed45..95020ff 100644 --- a/internal/api/types.go +++ b/internal/apidef/types.go @@ -1,4 +1,4 @@ -package api +package apidef /* (1) Configuration ---------------------------------------------------------*/ diff --git a/server.go b/server.go index 56c73e8..4d7604e 100644 --- a/server.go +++ b/server.go @@ -2,14 +2,14 @@ package aicra import ( "errors" + "git.xdrm.io/go/aicra/api" "git.xdrm.io/go/aicra/driver" e "git.xdrm.io/go/aicra/err" - "git.xdrm.io/go/aicra/internal/api" + "git.xdrm.io/go/aicra/internal/apidef" "git.xdrm.io/go/aicra/internal/checker" "git.xdrm.io/go/aicra/internal/config" apirequest "git.xdrm.io/go/aicra/internal/request" "git.xdrm.io/go/aicra/middleware" - "git.xdrm.io/go/aicra/response" "log" "net/http" "path/filepath" @@ -21,7 +21,7 @@ import ( // * its middlewares // * its controllers (api config) type Server struct { - controller *api.Controller // controllers + controller *apidef.Controller // controllers checker checker.Registry // type checker registry middleware middleware.Registry // middlewares schema *config.Schema @@ -46,7 +46,7 @@ func New(_path string) (*Server, error) { } /* 3. Load configuration */ - i.controller, err = api.Parse(_path) + i.controller, err = apidef.Parse(_path) if err != nil { return nil, err } @@ -166,7 +166,7 @@ func (s *Server) ServeHTTP(res http.ResponseWriter, req *http.Request) { return } - var ctlMethod func(response.Arguments) response.Response + var ctlMethod func(api.Arguments) api.Response // select method switch httpMethod { case "GET": @@ -214,7 +214,7 @@ func (s *Server) ServeHTTP(res http.ResponseWriter, req *http.Request) { // extractParameters extracts parameters for the request and checks // every single one according to configuration options -func (s *Server) extractParameters(req *apirequest.Request, methodParam map[string]*api.Parameter) (map[string]interface{}, e.Error) { +func (s *Server) extractParameters(req *apirequest.Request, methodParam map[string]*apidef.Parameter) (map[string]interface{}, e.Error) { // init vars err := e.Success diff --git a/util.go b/util.go index f5e1929..335549c 100644 --- a/util.go +++ b/util.go @@ -2,15 +2,15 @@ package aicra import ( "encoding/json" + "git.xdrm.io/go/aicra/api" "git.xdrm.io/go/aicra/err" - "git.xdrm.io/go/aicra/internal/api" - apirequest "git.xdrm.io/go/aicra/internal/request" - "git.xdrm.io/go/aicra/response" + "git.xdrm.io/go/aicra/internal/apidef" + apireq "git.xdrm.io/go/aicra/internal/request" "log" "net/http" ) -func (s *Server) matchController(req *apirequest.Request) *api.Controller { +func (s *Server) matchController(req *apireq.Request) *apidef.Controller { /* (1) Try to browse by URI */ pathi, ctl := s.controller.Browse(req.URI) @@ -34,7 +34,7 @@ func httpRedirect(r http.ResponseWriter, loc string) { } // Prints an HTTP response -func httpPrint(r http.ResponseWriter, res response.Response) { +func httpPrint(r http.ResponseWriter, res api.Response) { // get response data formattedResponse := res.Dump()