forked from vert-x3/vertx-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRoutingContextInternal.java
More file actions
136 lines (118 loc) · 3.99 KB
/
RoutingContextInternal.java
File metadata and controls
136 lines (118 loc) · 3.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
* Copyright 2014 Red Hat, Inc.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* The Apache License v2.0 is available at
* http://www.opensource.org/licenses/apache2.0.php
*
* You may elect to redistribute this code under either of these licenses.
*/
package io.vertx.ext.web.impl;
import io.vertx.codegen.annotations.CacheReturn;
import io.vertx.codegen.annotations.Nullable;
import io.vertx.core.buffer.Buffer;
import io.vertx.ext.auth.audit.SecurityAudit;
import io.vertx.ext.web.Router;
import io.vertx.ext.web.RoutingContext;
import io.vertx.ext.web.Session;
/**
* Internal methods that are not expected or prime to be in the public API
*
* @author Paulo Lopes
*/
public interface RoutingContextInternal extends RoutingContext {
int BODY_HANDLER = 1 << 1;
int CORS_HANDLER = 1 << 2;
int SESSION_HANDLER = 1 << 3;
int CSRF_HANDLER = 1 << 4;
/**
* flags the current routing context as having visited the handler with {@code id}.
* @param id one of the constants of this interface
* @return self
*/
RoutingContextInternal visitHandler(int id);
/**
* returns true if the current context has been visited by the handler with {@code id}.
*
* @param id one of the constants of this interface
* @return true if the {@link #visitHandler(int)} has been called with the same id.
*/
boolean seenHandler(int id);
/**
* propagates a matching failure across routers.
*
* @param matchFailure the desired match failure
* @return fluent self
*/
RoutingContextInternal setMatchFailure(int matchFailure);
/**
* adds allowed methods to the context for 405 responses.
*
* @param allowedMethods the allowed methods to add
* @return fluent self
*/
RoutingContextInternal addAllowedMethods(java.util.Set<io.vertx.core.http.HttpMethod> allowedMethods);
/**
* adds allowed content types to the context for 415 responses.
*
* @param allowedContentTypes the allowed content types to add
* @return fluent self
*/
RoutingContextInternal addAllowedContentTypes(java.util.Set<io.vertx.ext.web.MIMEHeader> allowedContentTypes);
/**
* @return the current router this context is being routed through. All routingContext is associated with a router and
* never returns null.
*/
@CacheReturn
Router currentRouter();
/**
* If a sub router is mounted to a parent router and the request is routed to the sub Router, two routingContexts are generated.
* sub routingContext associated sub router and {@code parent()} of sub routingContext associated parent router.
*
* @return the parent context for this context. It will be null for a top level router. For a sub-router of context has parent
*/
@CacheReturn
@Nullable RoutingContextInternal parent();
/**
* Set the body. Used by the {@link io.vertx.ext.web.handler.BodyHandler}.
*
* @param body the body
*/
void setBody(Buffer body);
/**
* Set the session. Used by the {@link io.vertx.ext.web.handler.SessionHandler}.
*
* @param session the session
*/
void setSession(Session session);
int restIndex();
boolean normalizedMatch();
default String basePath() {
// if we're on a sub router already we need to skip the matched path
String mountPoint = mountPoint();
int skip = mountPoint != null ? mountPoint.length() : 0;
if (normalizedMatch()) {
return normalizedPath().substring(skip, skip + restIndex());
} else {
String path = request().path();
if (path != null) {
return path.substring(skip, skip + restIndex());
}
return null;
}
}
/**
* Get or Default the security audit object.
*/
SecurityAudit securityAudit();
/**
* Get or Default the security audit object.
*/
void setSecurityAudit(SecurityAudit securityAudit);
}