Fix error 500
This commit is contained in:
parent
d9d602bb83
commit
b06ed20afd
3 changed files with 9 additions and 8 deletions
|
@ -28,7 +28,8 @@ public class Client<U extends User> extends Thread{
|
|||
reader.readHeaders();
|
||||
|
||||
RequestType type = RequestType.valueOf(headers[0]);
|
||||
context = router.exec(type, headers[1], isLogin(router, type, reader), reader, writer);
|
||||
context = new Context(type, headers[1], isLogin(router, type, reader), writer, router.getDefaultHeaders(type));
|
||||
router.exec(context, reader, writer);
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}catch(InvalidJwtException e){
|
||||
|
|
|
@ -31,9 +31,12 @@ public class RouteMapper{
|
|||
this.dif = 2;
|
||||
}
|
||||
|
||||
public boolean exec(Context context, String path, User user, HttpReader reader, HttpWriter writer) throws Exception{
|
||||
public boolean exec(Context context, HttpReader reader, HttpWriter writer) throws Exception{
|
||||
Response result = null;
|
||||
Matcher matcher = null;
|
||||
|
||||
String path = context.getPath();
|
||||
|
||||
synchronized(responses){
|
||||
for(int i = 0; i < responses.length; i++){
|
||||
Response response = responses[i];
|
||||
|
@ -41,7 +44,7 @@ public class RouteMapper{
|
|||
Pattern pattern = patterns[i];
|
||||
matcher = pattern.matcher(path);
|
||||
if(matcher.matches()){
|
||||
if(user == null && route.needLogin()){
|
||||
if((!context.isLogged()) && route.needLogin()){
|
||||
writer.response(401, "Access-Control-Allow-Origin: *");
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -96,12 +96,9 @@ public class Router<U extends User>{
|
|||
return this.headers[type.ordinal()];
|
||||
}
|
||||
|
||||
Context exec(RequestType type, String path, User user, HttpReader reader, HttpWriter writer) throws Exception{
|
||||
if(type == null) return null;
|
||||
Context context = new Context(type, path, user, writer, this.headers[type.ordinal()]);
|
||||
if(this.mappers[type.ordinal()].exec(context, path, user, reader, writer)) return context;
|
||||
void exec(Context context, HttpReader reader, HttpWriter writer) throws Exception{
|
||||
if(this.mappers[context.getType().ordinal()].exec(context, reader, writer)) return;
|
||||
if(noFileFound != null) noFileFound.exec(null, context, reader, writer);
|
||||
return context;
|
||||
}
|
||||
|
||||
public Router<U> configureSSL(String keyStore, String keyStorePassword){
|
||||
|
|
Loading…
Add table
Reference in a new issue