Skip to content

Commit 92d5939

Browse files
committed
Update template docs for newer Java11 templates
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
1 parent c374291 commit 92d5939

File tree

1 file changed

+42
-31
lines changed

1 file changed

+42
-31
lines changed

docs/cli/templates.md

Lines changed: 42 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,48 @@ npm i --save cheerio
429429

430430
You can now add a `require('cheerio')` statement into your function and make use of this library.
431431

432+
433+
#### Java
434+
435+
Two Java templates are provided `java11` and `java11-vertx`, both of which use Gradle as the build system. Please note that the `java8` template is deprecated, and should not be used.
436+
437+
> If you need a different version, then please fork the templates repository, or contact sales@openfaas.com to access additional templates via your OpenFaaS Premium Subscription.
438+
439+
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.
440+
441+
* Write a function `java-function`:
442+
443+
```
444+
$ faas-cli new --lang java11 java-function
445+
```
446+
447+
* Write your code in:
448+
449+
./src/main/Handler.java
450+
451+
* Write `junit` tests in:
452+
453+
./src/tests/
454+
455+
* Update gradle config if needed in:
456+
457+
./build.gradle
458+
./settings.gradle
459+
460+
* Working with headers (advanced)
461+
462+
You can view the code for the IRequest and IResponse in [the OpenFaaS templates-sdk](https://github.com/openfaas/templates-sdk/tree/master/java11/model/src/main/java/com/openfaas/model)
463+
464+
You can use `getHeader(k)` on the Request interface to query a header.
465+
466+
To set a header such as content-type you can use `setHeader(k, v)` on the Response interface.
467+
468+
You can also run the following to create a function using Vert.x
469+
470+
```bash
471+
$ faas-cli new --lang java11-vertx java-vertx-function
472+
```
473+
432474
#### CSharp / .NET Core 2.1
433475

434476
You can create functions in .NET Core 2.1 using C# / CSharp.
@@ -522,37 +564,6 @@ $ echo 'OpenFaaS' | faas-cli invoke ruby-function
522564
...
523565
```
524566
525-
#### Java (of-watchdog)
526-
527-
Two Java templates are provided `java8` and `java12`, if you need a different version, then please fork the templates repo or request it from the community.
528-
529-
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.
530-
531-
* Write a function `java-function`:
532-
533-
```
534-
$ faas-cli new --lang java8 java-function
535-
```
536-
537-
* Write your code in:
538-
539-
./src/main/Handler.java
540-
541-
* Write `junit` tests in:
542-
543-
./src/tests/
544-
545-
* Update gradle config if needed in:
546-
547-
./build.gradle
548-
./settings.gradle
549-
550-
* Working with headers
551-
552-
You can use `getHeader(k)` on the Request interface to query a header.
553-
554-
To set a header such as content-type you can use `setHeader(k, v)` on the Response interface.
555-
556567
#### PHP7
557568
558569
To create a PHP7 function named `my-function` type in:

0 commit comments

Comments
 (0)