From 7bcbefdf35ea106439d8c6ac25bb450c77fc446c Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Mon, 1 Oct 2018 14:15:00 +0200 Subject: [PATCH] rename 'internal/config' to 'internal/api' | rename 'internal.api.Load()' to 'internal.api.Parse()' --- internal/{config => api}/controller.go | 6 +++--- internal/{config => api}/method.go | 2 +- internal/{config => api}/types.go | 2 +- server.go | 10 +++++----- util.go | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) rename internal/{config => api}/controller.go (97%) rename internal/{config => api}/method.go (97%) rename internal/{config => api}/types.go (97%) diff --git a/internal/config/controller.go b/internal/api/controller.go similarity index 97% rename from internal/config/controller.go rename to internal/api/controller.go index 7398262..ecc3c7f 100644 --- a/internal/config/controller.go +++ b/internal/api/controller.go @@ -1,4 +1,4 @@ -package config +package api import ( "encoding/json" @@ -7,7 +7,7 @@ import ( "strings" ) -// Load builds a representation of the configuration +// Parse builds a representation of the configuration // The struct definition checks for most format errors // // path The path to the configuration @@ -15,7 +15,7 @@ import ( // @return The parsed configuration root controller // @return The error if occurred // -func Load(path string) (*Controller, error) { +func Parse(path string) (*Controller, error) { /* (1) Extract data ---------------------------------------------------------*/ diff --git a/internal/config/method.go b/internal/api/method.go similarity index 97% rename from internal/config/method.go rename to internal/api/method.go index 03fb08e..5821209 100644 --- a/internal/config/method.go +++ b/internal/api/method.go @@ -1,4 +1,4 @@ -package config +package api import ( "git.xdrm.io/go/aicra/middleware" diff --git a/internal/config/types.go b/internal/api/types.go similarity index 97% rename from internal/config/types.go rename to internal/api/types.go index 87f7bb6..d92b64d 100644 --- a/internal/config/types.go +++ b/internal/api/types.go @@ -1,4 +1,4 @@ -package config +package api /* (1) Configuration ---------------------------------------------------------*/ diff --git a/server.go b/server.go index 6598eaf..b1e4921 100644 --- a/server.go +++ b/server.go @@ -3,8 +3,8 @@ package aicra import ( "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/checker" - "git.xdrm.io/go/aicra/internal/config" apirequest "git.xdrm.io/go/aicra/internal/request" "git.xdrm.io/go/aicra/middleware" "log" @@ -14,9 +14,9 @@ import ( // Server represents an AICRA instance featuring: // * its type checkers // * its middlewares -// * its controllers (config) +// * its controllers (api config) type Server struct { - controller *config.Controller // controllers + controller *api.Controller // controllers checker *checker.Registry // type checker registry middleware *middleware.Registry // middlewares driver driver.Driver @@ -50,7 +50,7 @@ func New(_path string, _driver driver.Driver) (*Server, error) { } /* (2) Load configuration */ - i.controller, err = config.Load(_path) + i.controller, err = api.Parse(_path) if err != nil { return nil, err } @@ -145,7 +145,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]*config.Parameter) (map[string]interface{}, e.Error) { +func (s *Server) extractParameters(req *apirequest.Request, methodParam map[string]*api.Parameter) (map[string]interface{}, e.Error) { // init vars err := e.Success diff --git a/util.go b/util.go index fdd7a82..f5e1929 100644 --- a/util.go +++ b/util.go @@ -3,14 +3,14 @@ package aicra import ( "encoding/json" "git.xdrm.io/go/aicra/err" - "git.xdrm.io/go/aicra/internal/config" + "git.xdrm.io/go/aicra/internal/api" apirequest "git.xdrm.io/go/aicra/internal/request" "git.xdrm.io/go/aicra/response" "log" "net/http" ) -func (s *Server) matchController(req *apirequest.Request) *config.Controller { +func (s *Server) matchController(req *apirequest.Request) *api.Controller { /* (1) Try to browse by URI */ pathi, ctl := s.controller.Browse(req.URI)