Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More details in njs scripting how-to. #101

Open
hongzhidao opened this issue Feb 19, 2024 · 0 comments
Open

More details in njs scripting how-to. #101

hongzhidao opened this issue Feb 19, 2024 · 0 comments

Comments

@hongzhidao
Copy link

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
                }
            }
        ]
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant