{"id":28003168,"url":"https://github.com/fnproject/fn-jrestless-example","last_synced_at":"2025-10-14T09:37:20.070Z","repository":{"id":27253378,"uuid":"104888869","full_name":"fnproject/fn-jrestless-example","owner":"fnproject","description":"Run JAX-RS applications on Fn using JRestless ","archived":false,"fork":false,"pushed_at":"2024-10-03T18:03:40.000Z","size":202,"stargazers_count":8,"open_issues_count":4,"forks_count":7,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-05-09T01:59:16.384Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fnproject.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-26T13:33:37.000Z","updated_at":"2022-04-21T02:54:04.000Z","dependencies_parsed_at":"2022-08-24T05:51:34.082Z","dependency_job_id":null,"html_url":"https://github.com/fnproject/fn-jrestless-example","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnproject%2Ffn-jrestless-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnproject%2Ffn-jrestless-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnproject%2Ffn-jrestless-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnproject%2Ffn-jrestless-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fnproject","download_url":"https://codeload.github.com/fnproject/fn-jrestless-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253176436,"owners_count":21866142,"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":[],"created_at":"2025-05-09T01:59:21.607Z","updated_at":"2025-10-14T09:37:15.021Z","avatar_url":"https://github.com/fnproject.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fn Project JRestless Blogging Example\n\nAuthor: [Rae Jeffries-Harris](https://github.com/RaeJ) \n\nThis is an example JAX-RS app that can be deployed on the Fn platform.\n\n## What?\n\n[JRestless](http://github.com/bbilger/jrestless) allows you to create FaaS applications using [JAX-RS](https://github.com/jax-rs).\nWe are adding [support for using JRestless on Fn](https://github.com/bbilger/jrestless/pull/43).\n\nThis means you can use all the JAX-RS features you're used to, `@Path`, `@GET`, `@QueryParam` -\nall the marshalling and content-types, all the routing. All of it, in a FaaS function. JRestless uses\n[Jersey](https://jersey.github.io/) internally so you have the full capability of the reference JAX-RS\nimplementation.\n\nIf you take advantage of [FnProject's Hot Functions](https://github.com/fnproject/fn/blob/master/docs/hot-functions.md)\nyou can build a responsive application which only runs when it's needed.\n\nThis project is an example of how to use JRestless build a JAX-RS app on FnProject.\n\n## How does it work?\n\nThe code in `com.example.fnjrestless.blog` is a JAX-RS app:\n\n  * `BloggingResource.java` - defines the routes\n  * `BloggPost.java` - POJO domain object\n  * `BlogStore.java` - Database connection code\n  * `BloggingApp.java` - 5 lines of code to point JRestless at our app\n  \nCheck out the code, then in the root of the project run:\n\n```shell\n$ fn build\n\n...snip...\n\nFunction raej/jrest:0.0.4 built successfully.\n```\n\nMake sure you have an fn server running (See [the tutorial](https://github.com/fnproject/tutorials/tree/master/Introduction#starting-fn-server) - TL;DR `fn start`)\n\nThen create your app:\n\n```shell\n$ fn apps create jaxrs\nSuccessfully created app:  jaxrs\n\n$ fn deploy --app jaxrs --local\n```\n\nYou will need a database, easy way is to run the `./start-mysql.sh` included in the repo.\n\nSome config for your app:\n\n```shell\n## The IP address of the host from inside a container\n$ export DOCKER_HOST_IP=$(docker inspect --type container -f '{{.NetworkSettings.Gateway}}' fnserver)\n\nfn apps config set jaxrs DB_URL \"jdbc:mysql://${DOCKER_HOST_IP}/POSTS\"\nfn apps config set jaxrs DB_DRIVER com.mysql.jdbc.Driver\nfn apps config set jaxrs DB_USER jaxrs\nfn apps config set jaxrs DB_PASSWORD SgRoV3s\n```\n\nMap the routes used by the app to the function:\n(use whichever image version was published in the previous deploy )\n\n```shell\nfn routes create jaxrs /route/html --image raej/jrest:0.0.2\nfn routes create jaxrs /route/blogs --image raej/jrest:0.0.2\n# fn routes create jaxrs /route/add  \u003c-- this was added by `fn deploy` earlier\n```\n\nAll 3 of these routes will point to the same container image.\n\n## Bask in the glory of your creation\n\nBrowse to [http://localhost:8080/r/jaxrs/route/html](http://localhost:8080/r/jaxrs/route/html) to see the blog's UI.\n\nThere is a simple HTML page served from `/html`, which fetches data from `/blogs` and posts new blog entries to `/add`.\n\n## FAQ / Notes\n\n### QUESTION: How many Function containers will be used?\n\nFn treats each route independently, so there will be *at least* one per endpoint that you use. There may be more than one, as container instances will be created dynamically to cope with high load.\n\n\n### QUESTION: What about binding variables from path params?\n\nFn currently does not support wildcards in routes. Issues [#170](https://github.com/fnproject/fn/issues/170) and [#256](https://github.com/fnproject/fn/issues/256) track current proposals to fix this.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnproject%2Ffn-jrestless-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffnproject%2Ffn-jrestless-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnproject%2Ffn-jrestless-example/lists"}