diff --git a/docs/cli/templates.md b/docs/cli/templates.md index ab4812b9..e3fef8ff 100644 --- a/docs/cli/templates.md +++ b/docs/cli/templates.md @@ -129,13 +129,44 @@ npm i --save cheerio You can now add a `require('cheerio')` statement into your function and make use of this library. -## 4.0 Customise a template +## 4.0 Java + +A Java 8 template is provided which uses Gradle 4.8.1 as a build-system. + +Support is made available for external code repositories via the build.gradle file where you specify dependencies to fetch from repositories or JAR files to be added via the build. + +* Write a function `java-function`: + +``` +$ faas-cli new --lang java8 java-function +``` + +* Write your code in: + +./src/main/Handler.java + +* Write `junit` tests in: + +./src/tests/ + +* Update gradle config if needed in: + +./build.gradle +./settings.gradle + +* Working with headers + +You can use `getHeader(k)` on the Request interface to query a header. + +To set a header such as content-type you can use `setHeader(k, v)` on the Response interface. + +## 5.0 Customise a template It is recommended that you use the official templates as they are provided and if there is a short-coming that you raise a GitHub issue so we can improve the templates for everyone. All templates are driven by a Dockerfile and can be customised by editing the files found in the ./template folder. -### 4.1 Update the Dockerfile +### 5.1 Update the Dockerfile There are several reasons why you may want to update your Dockerfile, just edit `./template//Dockerfile`. @@ -145,7 +176,7 @@ There are several reasons why you may want to update your Dockerfile, just edit * Try a new version of a base-image - it may be that the project is showing support for Node.js LTS, but you want the cutting-edge version, you can do that too -### 4.2 Update a template's configuration +### 5.2 Update a template's configuration The name of a template is read from a "template.yml" file kept within the template folder: `./template//template.yml` @@ -159,13 +190,13 @@ fprocess: dotnet ./root.dll * `language` is the display name used for `faas-cli new --list`. * `fprocess` provides the process to run for each invocation - i.e. your function -### 4.3 Use your own templates +### 5.3 Use your own templates You can use your own Git repository for a custom or forked set of templates. This can be public or private. See `faas-cli template pull` for more information. -### 5.0 ARM / Raspberry Pi +### 6.0 ARM / Raspberry Pi Templates for ARM and Raspberry Pi are provided on a best-effort basis. If you can help with maintenance please let the project contributors know.