menu

SFRA / Server-side JS / Tutorial: Controllers

Controllers

Defining a public endpoint

To create a public endpoint you simply need to define a function and use the guard to define access control. Let's assume for our case that we want our Hello World example only to be accessible via HTTP GET .

Generating the output

For the sake of simplicity, let's just write Hello World! to the response, of course you can also use templates to render more sophisticated pages which is explained in the next chapter.

Generating output by rendering templates