Skip to content

More details in njs scripting how-to. #101

Open
@hongzhidao

Description

@hongzhidao

Hi,
I didn't see any example of how to import njs in the configuration, let me know if I missed it.
For example, here's my demo:

{
    "settings": {
        "js_module": "http"
    },

Based on it, I'd suggesting showing an full example in https://unit.nginx.org/scripting/#examples, for example:

{
    "settings": {
        "js_module": "http"
    },
    "listeners": {
        "*:8080": {
            "pass": "`routes/${http.route(headers)}`"
        }
    },
    "routes": {
        "unauthorized": [
            {
                "action": {
                    "return": 401
                }
            }
        ],

        "forbidden": [
            {
                "action": {
                    "return": 403
                }
            }
        ],

        "accept": [
            {
                "action": {
                    "return": 204
                }
            }
        ]
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions