rename 'internal/config' to 'internal/api' | rename 'internal.api.Load()' to 'internal.api.Parse()'

This commit is contained in:
Adrien Marquès 2018-10-01 14:15:00 +02:00
parent fd6d7b661e
commit 7bcbefdf35
5 changed files with 12 additions and 12 deletions

View File

@ -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<string> The path to the configuration
@ -15,7 +15,7 @@ import (
// @return<controller> The parsed configuration root controller
// @return<err> The error if occurred
//
func Load(path string) (*Controller, error) {
func Parse(path string) (*Controller, error) {
/* (1) Extract data
---------------------------------------------------------*/

View File

@ -1,4 +1,4 @@
package config
package api
import (
"git.xdrm.io/go/aicra/middleware"

View File

@ -1,4 +1,4 @@
package config
package api
/* (1) Configuration
---------------------------------------------------------*/

View File

@ -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

View File

@ -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)