Mercurial Hosting > luan
annotate src/goodjava/webserver/Status.java @ 1630:b735ed134662
add nginx and ssl for host
author | fffilimonov |
---|---|
date | Fri, 10 Dec 2021 17:08:17 +0000 |
parents | f7e3adae4907 |
children |
rev | line source |
---|---|
1402
27efb1fcbcb5
move luan.lib to goodjava
Franklin Schmidt <fschmidt@gmail.com>
parents:
1347
diff
changeset
|
1 package goodjava.webserver; |
1137 | 2 |
1155 | 3 import java.util.Map; |
4 import java.util.HashMap; | |
1402
27efb1fcbcb5
move luan.lib to goodjava
Franklin Schmidt <fschmidt@gmail.com>
parents:
1347
diff
changeset
|
5 import goodjava.logging.Logger; |
27efb1fcbcb5
move luan.lib to goodjava
Franklin Schmidt <fschmidt@gmail.com>
parents:
1347
diff
changeset
|
6 import goodjava.logging.LoggerFactory; |
1155 | 7 |
1137 | 8 |
9 public class Status { | |
1155 | 10 private static final Logger logger = LoggerFactory.getLogger(Status.class); |
11 | |
1137 | 12 public final int code; |
13 public final String reason; | |
14 | |
15 public Status(int code,String reason) { | |
16 this.code = code; | |
17 this.reason = reason; | |
18 } | |
19 | |
1155 | 20 private static final Map<Integer,Status> map = new HashMap<Integer,Status>(); |
21 | |
22 protected static Status newStatus(int code,String reason) { | |
23 Status status = new Status(code,reason); | |
24 map.put(code,status); | |
25 return status; | |
26 } | |
27 | |
28 public static Status getStatus(int code) { | |
29 Status status = map.get(code); | |
30 if( status == null ) { | |
31 logger.warn("missing status "+code); | |
32 status = new Status(code,""); | |
33 } | |
34 return status; | |
35 } | |
36 | |
37 public static final Status OK = newStatus(200,"OK"); | |
38 public static final Status MOVED_PERMANENTLY = newStatus(301,"Moved Permanently"); | |
1160 | 39 public static final Status FOUND = newStatus(302,"Found"); |
1604
8a7519dee55c
FileHandler handles if-modified-since
Franklin Schmidt <fschmidt@gmail.com>
parents:
1402
diff
changeset
|
40 public static final Status NOT_MODIFIED = newStatus(304,"Not Modified"); |
1194
bd0420fb3dd0
handle ParseException in webserver
Franklin Schmidt <fschmidt@gmail.com>
parents:
1160
diff
changeset
|
41 public static final Status BAD_REQUEST = newStatus(400,"Bad Request"); |
1608
f7e3adae4907
add BasicAuthHandler
Franklin Schmidt <fschmidt@gmail.com>
parents:
1604
diff
changeset
|
42 public static final Status UNAUTHORIZED = newStatus(401,"Unauthorized"); |
1155 | 43 public static final Status NOT_FOUND = newStatus(404,"Not Found"); |
44 public static final Status INTERNAL_SERVER_ERROR = newStatus(500,"Internal Server Error"); | |
1137 | 45 } |