diff --git a/.gitignore b/.gitignore index e056435..a10ba1e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.so /types +/controllers /test \ No newline at end of file diff --git a/README.md b/README.md index 3c7ef42..a2e1333 100644 --- a/README.md +++ b/README.md @@ -11,16 +11,27 @@ It is based on the *all-in-config* idea, where you only have a configuration fi -Here's a taste of some features: -- human-readable json configuration -- nested routes (*i.e. `/user/:id:` vs. `/user/post/​:id:​`*) -- useful http methods: GET, POST, PUT, DELETE -- manage URL, query and body arguments: - - multipart/form-data - - application/x-www-form-urlencoded - - application/json -- required vs. optional parameters with a default value -- parameter renaming -- generic authentication system (*i.e. you can override the built-in*) -- generic type check (*i.e. implement your types alongside built-in types*) \ No newline at end of file +##### changelog + +- [x] human-readable json configuration +- [x] nested routes (*i.e. `/user/:id:` and `/user/post/​:id:​`*) +- [ ] nested URL arguments (*i.e. `/user/:id:` and `/user/:id:/post/​:id:​`*) +- [x] useful http methods: GET, POST, PUT, DELETE +- [x] manage URL, query and body arguments: + - [x] multipart/form-data (variables and file uploads) + - [x] application/x-www-form-urlencoded + - [x] application/json +- [x] required vs. optional parameters with a default value +- [x] parameter renaming +- [ ] generic authentication system (*i.e. you can override the built-in one*) +- [x] generic type check (*i.e. implement custom types alongside built-in ones*) +- [ ] built-in types + - [x] `any` - wildcard matching all values + - [x] `int` - any number (*e.g. float, int, uint*) + - [x] `string` - any text + - [x] `varchar(min, max)` - any string with a length between `min` and `max` + - [ ] `` - array containing **only** elements matching `a` type + - [ ] `` - map containing **only** keys of type `a` and values of type `b` (*a or b can be ommited*) +- [ ] generic controllers implementation (shared objects) +- [ ] response interface \ No newline at end of file diff --git a/build-controllers.sh b/build-controllers.sh new file mode 100644 index 0000000..babbefd --- /dev/null +++ b/build-controllers.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# (1) Check argument +#--------------------------------------------------------# +if [ "$#" -lt 1 -o ! -d "$1" ]; then + echo -e "\e[33mERROR\e[0m missing parameter\n" + echo -e "+ expected first argument to be the controller's folder" + exit 1; +fi + + + +# (1) Get controller path # +BASE_DIR="`realpath $(pwd)`" +CTL_PATH="`realpath $1`"; + +# (2) List go files # +cd $CTL_PATH +GO_FILES="`ls *.go **/*.go`" + +# (3) Create target directory in execution dir # +mkdir -p $BASE_DIR/controllers; + +# (4) Build each file # +d=1 +for file in $GO_FILES; do + ctl="${file%.*}" # remove extension from path + echo -e "($d) Building \e[33m$ctl\e[0m"; + # build into execution dir + go build -buildmode=plugin -ldflags "-s -w" -o "$BASE_DIR/controllers/$ctl.so" ./$file; + + # Manage failure + if [ "$?" -ne "0" ]; then + echo -e "\e[31m/!\\ \e[0merror building \e[33m$ctl\e[0m\n" + fi + + d=""`expr $d + 1`"" +done; + +# (5) ACK # +echo -e "\n[ \e[32mfinished\e[0m ]\n" +echo -e "files are located inside the relative \e[33m./controllers\e[0m directory" \ No newline at end of file diff --git a/install-default-types.sh b/build-types.sh similarity index 100% rename from install-default-types.sh rename to build-types.sh