jensjeflensje / websk

Create websites using Skript!
MIT License
9 stars 4 forks source link

🚀 Added way to get specific header of request #36

Closed Norbiros closed 2 years ago

Norbiros commented 2 years ago

Now you can get header and read it due to #23. It is nessesary if you want get for example browser that connect to your webpage, or language of request.

Tested on minecraft server!

LowScarlet commented 2 years ago

how to use it

Norbiros commented 2 years ago

For example like this: if header "Accept-Language" of the request starts with "en-US":

In some files, you can find tags like @Examples

@Name("Request Header")
@Description({"When connection is made, client send data about it. ",
        "You can access to them using this code!)"})
@Since("1.2.1")
@Examples({"return header \"User-Agent\" of the request",
        "if header \"Accept-Language\" of the request starts with \"en-US\":"})
ItsTheSky commented 2 years ago

Use SimplePropertyExpression instead of SimpleExpression. If you still want to keep the actual code, don't forget to null-check the expression & the parsed value.

Norbiros commented 2 years ago

Sorry, but I don't understand. This code is practically copy of request's param, if there we don't use it, we I need to use it here? But yes, I can use it...