-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from ngn13/1.7-dev
1.7
- Loading branch information
Showing
31 changed files
with
279 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,6 @@ jobs: | |
|
||
- name: 'run example #4' | ||
run: ./scripts/test.sh 4 | ||
|
||
- name: 'run example #5' | ||
run: ./scripts/test.sh 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM ghcr.io/ngn13/ctorm:latest | ||
|
||
WORKDIR /example | ||
COPY . ./ | ||
|
||
RUN mkdir /dist | ||
RUN make \ | ||
DONT_CHECK_LIBCTORM=1 \ | ||
INCD=/usr/include/ctorm \ | ||
DIST=/dist | ||
|
||
WORKDIR / | ||
CMD ["/example/init.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
# docker init script | ||
|
||
examples=() | ||
pids=() | ||
|
||
for example in dist/*; do | ||
examples+=("${example}") | ||
done | ||
|
||
for i in "${!examples[@]}"; do | ||
"./${examples[$i]}" & | ||
pids[$i]=$! | ||
done | ||
|
||
for i in "${!pids[@]}"; do | ||
if ! wait "${pids[$i]}"; then | ||
echo "${examples[$i]} exited with a non zero exit-code (${?})" | ||
exit 1 | ||
fi | ||
done | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <ctorm.h> | ||
|
||
void GET_index(ctorm_req_t *req, ctorm_res_t *res) { | ||
char *username = REQ_LOCAL("username"); | ||
char *format = REQ_LOCAL("format"); | ||
RES_FMT(format, username); | ||
} | ||
|
||
void username_middleware(ctorm_req_t *req, ctorm_res_t *res) { | ||
char *username = REQ_QUERY("username"); | ||
|
||
if (NULL == username) { | ||
RES_SEND("no username provided"); | ||
REQ_CANCEL(); | ||
return; | ||
} | ||
|
||
REQ_LOCAL("username", username); | ||
} | ||
|
||
int main() { | ||
// create the app | ||
ctorm_app_t *app = ctorm_app_new(NULL); | ||
|
||
// add a global local | ||
ctorm_app_local(app, "format", "username: %s"); | ||
|
||
// setup the routes | ||
MIDDLEWARE_GET(app, "/*", username_middleware); | ||
GET(app, "/", GET_index); | ||
|
||
// run the app | ||
if (!ctorm_app_run(app, "0.0.0.0:8083")) | ||
ctorm_fail("failed to start the app: %s", ctorm_geterror()); | ||
|
||
// clean up | ||
ctorm_app_free(app); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.