Written in GO. Using gin web framework. Using docker to run code in containers.
- When SCR receive a post request, it will start a container and put the payload to container’s stdin then wait till this container stop or exit with error.
- While SCR is waiting, a program(ric) inside the container will take the payload and run those code, ric will put those code’s result to container’s stdout(include stdout stderr and exit status), if ric got error it will put error to container’s stderr and exit with non-zero value.
- Finally SCR get error or container’s stdout and stderr, then send response to client.
- build them in docker or use local go environment.
- run `make` to build images and start the api container, or you can pull containers from Docker Hub, you can read the Makefile to finger it out.
Method | Path | Description |
---|---|---|
Get | /v1 | all languages and versions |
Get | /v1/language | all version of one language |
POST | /v1/language | run code use default version of one language |
POST | /v1/language/version | run code use a specific version of one language |
Http status code | Description | example data |
---|---|---|
200 | OK | {“userResult”:{“stdout”:”“,”stderr”:”“,”exiterror”:”“},”taskError”:”“} |
400 | language is not supported | “java++ is not support” |
version is not supported | “java openjdk-100 is not support” | |
request data not valid | “json: cannot unmarshal…” | |
500 | Internal Server Error | “xxxx” |
curl -X GET http://localhost:8080/v1/c
[
{
"name": "c",
"versions": [
{
"version": "gcc10",
"url": "/v1/c/gcc10"
}
]
}
]
curl -X POST http://localhost:8090/v1/c -H 'Content-Type: application/json' -d '{ "files" : [ { "content" : "#include<stdio.h>\n\nint main()\n{\n printf(\"Hello, World!\\n\");\n}", "name" : "main.c" } ], "stdin":"", "argument":{ "compile": ["gcc", "-Wall"] } } ' { "userResult": { "stdout": "Hello, World!\n", "stderr": "", "exitError": "" }, "taskError": "" }
This project has been supported by JetBrains with their free licenses.