Skip to content

Commit 5444cb0

Browse files
committed
fix(webapi) fix authorization header reference
1 parent d4f4bf1 commit 5444cb0

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

instruction/web-api/web-api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ Javalin.create()
8181

8282
## HTTP Headers
8383

84-
In addition to passing information through the HTTP path and body, you can pass information using HTTP headers. For example, if you needed a valid authorization token for some of your endpoints then you could write a method that gets a authorization HTTP header and checks the value against an existing list of valid tokens. If the token is not provided in the HTTP `authentication` header, or it is not valid then an HTTP 401 status code is returned.
84+
In addition to passing information through the HTTP path and body, you can pass information using HTTP headers. For example, if you needed a valid authorization token for some of your endpoints then you could write a method that gets a authorization HTTP header and checks the value against an existing list of valid tokens. If the token is not provided in the HTTP `authorization` header, or it is not valid then an HTTP 401 status code is returned.
8585

8686
```java
8787
final private HashSet<String> validTokens = new HashSet<>(Set.of("secret1", "secret2"));
8888

8989
private boolean authorized(Context ctx) {
90-
String authToken = ctx.header("authentication");
90+
String authToken = ctx.header("authorization");
9191
if (!validTokens.contains(authToken)) {
9292
ctx.contentType("application/json");
9393
ctx.status(401);

0 commit comments

Comments
 (0)