{"id":23445928,"url":"https://github.com/fission/fission-restapi-sample","last_synced_at":"2025-04-13T15:11:46.652Z","repository":{"id":35101595,"uuid":"145364595","full_name":"fission/fission-restapi-sample","owner":"fission","description":"A RESTful API sample build on top of fission","archived":false,"fork":false,"pushed_at":"2022-03-08T05:12:03.000Z","size":19,"stargazers_count":3,"open_issues_count":0,"forks_count":3,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-27T06:05:45.410Z","etag":null,"topics":["fission","golang","kuberne","restful-api","serverless"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fission.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-20T04:07:58.000Z","updated_at":"2022-03-13T12:44:33.000Z","dependencies_parsed_at":"2022-08-08T05:01:12.330Z","dependency_job_id":null,"html_url":"https://github.com/fission/fission-restapi-sample","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fission%2Ffission-restapi-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fission%2Ffission-restapi-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fission%2Ffission-restapi-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fission%2Ffission-restapi-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fission","download_url":"https://codeload.github.com/fission/fission-restapi-sample/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248732489,"owners_count":21152852,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fission","golang","kuberne","restful-api","serverless"],"created_at":"2024-12-23T20:28:26.986Z","updated_at":"2025-04-13T15:11:46.630Z","avatar_url":"https://github.com/fission.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RESTful API in Golang\n\nIn this sample, we create a simple guestbook application to demonstrates how to create a set of CURD RESTful APIs with fission function.\n\n## Installation\n\n1. Add the cockroachdb helm chart\n\n```bash\nhelm repo add cockroachdb https://charts.cockroachdb.com/\nhelm repo update\n```\n\n2. Install cockroachdb operator using helm\n\n```bash\nhelm install my-release --values cockroachdb.yaml cockroachdb/cockroachdb\n```\n\n3. Zip the files in the rest-api folder\n\n```bash\nzip -j restapi-go-pkg.zip rest-api/*\n```\n\n4. Use `fission spec` to create application\n\n```bash\nfission spec apply\n```\n\n5. Check application status\n\nAfter `fission spec apply`, you can check that functions, http triggers and package are successfully created.\n\n```bash\n$ fission spec list\nFunctions:\nNAME           ENV EXECUTORTYPE MINSCALE MAXSCALE MINCPU MAXCPU MINMEMORY MAXMEMORY TARGETCPU SECRETS CONFIGMAPS\nrestapi-delete go  newdeploy    1        3        0      0      0         0         80                \nrestapi-get    go  newdeploy    1        3        0      0      0         0         80                \nrestapi-post   go  newdeploy    1        3        0      0      0         0         80                \nrestapi-update go  newdeploy    1        3        0      0      0         0         80                \n\nEnvironments:\nNAME IMAGE               BUILDER_IMAGE           POOLSIZE MINCPU MAXCPU MINMEMORY MAXMEMORY EXTNET GRACETIME\ngo   fission/go-env-1.16 fission/go-builder-1.16 3        0      0      0         0         false  0\n\nPackages:\nNAME           BUILD_STATUS ENV LASTUPDATEDAT\nrestapi-go-pkg succeeded    go  04 Mar 22 14:31 IST\n\nHTTP Triggers:\nNAME        METHOD   URL                             FUNCTION(s)    INGRESS HOST PATH                            TLS ANNOTATIONS\nrestdelete  [DELETE] /guestbook/messages/{id:[0-9]+} restapi-delete false   *    /guestbook/messages/{id:[0-9]+}     \nrestget     [GET]    /guestbook/messages/            restapi-get    false   *    /guestbook/messages/                \nrestgetpart [GET]    /guestbook/messages/{id:[0-9]+} restapi-get    false   *    /guestbook/messages/{id:[0-9]+}     \nrestpost    [POST]   /guestbook/messages             restapi-post   false   *    /guestbook/messages                 \nrestupdate  [PUT]    /guestbook/messages/{id:[0-9]+} restapi-update false   *    /guestbook/messages/{id:[0-9]+}     \n\n```\n\nIf the build status of the package shows failed, try rebuilding it.\n\n```bash\nfission pkg rebuild --name restapi-go-pkg\n```\n\n## Usage\n\n1. Create a post\n\n```bash\n$ curl -v -X POST \\\n    http://${FISSION_ROUTER}/guestbook/messages \\\n    -H 'Content-Type: application/json' \\\n    -d '{\"message\": \"hello world!\"}'\n```\n\n2. Get all posts/single post\n\n```bash\ncurl -v -X GET http://${FISSION_ROUTER}/guestbook/messages/\n```\n\nYou should see a list posts are returned.\n\n```json\n[\n    {\n        \"id\": 366739357484417025,\n        \"message\": \"hello world!\",\n        \"timestamp\": 1531990369\n    },\n    {\n        \"id\": 366739413774237697,\n        \"message\": \"hello world!\",\n        \"timestamp\": 1531990387\n    },\n    {\n        \"id\": 366739416644550657,\n        \"message\": \"hello world!\",\n        \"timestamp\": 1531990399\n    }\n]\n```\n\nNow, let's try to get a single post with post `id`.\n\n```bash\ncurl -v -X GET http://${FISSION_ROUTER}/guestbook/messages/366456868654284801\n```\n\nOr, you can try to get the messages in a specific time range with `start` and `end`.\n\n```bash\ncurl -X GET 'http://${FISSION_ROUTER}/guestbook/messages/?start=1531990369\u0026end=1531990387'\n```\n\n3. Update post\n\n```bash\n$ curl -v -X PUT \\\n    http://${FISSION_ROUTER}/guestbook/messages/366456868654284801 \\\n    -H 'Content-Type: application/json' \\\n    -d '{\"message\": \"hello world again!\"}'\n```\n\n4. Delete post\n\n```bash\n$ curl -X DELETE \\\n    http://${FISSION_ROUTER}/guestbook/messages/366456868654284801 \\\n    -H 'Cache-Control: no-cache'\n```\n\n## Spec generation\n\n```console\nfission spec init\nfission env create --name go --image fission/go-env-1.16 --builder fission/go-builder-1.16 --spec\nfission pkg create --name restapi-go-pkg --src restapi-go-pkg.zip --env go --spec\nfission fn create --name restapi-delete --executortype newdeploy --maxscale 3 --env go --pkg restapi-go-pkg --entrypoint MessageDeleteHandler --spec\nfission fn create --name restapi-update --executortype newdeploy --maxscale 3 --env go --pkg restapi-go-pkg --entrypoint MessageUpdateHandler --spec\nfission fn create --name restapi-post --executortype newdeploy --maxscale 3 --env go --pkg restapi-go-pkg --entrypoint MessagePostHandler --spec\nfission fn create --name restapi-get --executortype newdeploy --maxscale 3 --env go --pkg restapi-go-pkg --entrypoint MessageGetHandler --spec\nfission httptrigger create --url /guestbook/messages --method POST --function restapi-post --spec --name restpost\nfission httptrigger create --url \"/guestbook/messages/{id:[0-9]+}\" --method PUT --function restapi-update --spec --name restupdate\nfission httptrigger create --url \"/guestbook/messages/{id:[0-9]+}\" --method GET --function restapi-get --spec --name restgetpart\nfission httptrigger create --url \"/guestbook/messages/{id:[0-9]+}\" --method DELETE --function restapi-delete --spec --name restdelete\nfission httptrigger create --url \"/guestbook/messages/\" --method GET --function restapi-get --spec --name restget\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffission%2Ffission-restapi-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffission%2Ffission-restapi-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffission%2Ffission-restapi-sample/lists"}