-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathServerMain.java
More file actions
83 lines (71 loc) · 2.85 KB
/
ServerMain.java
File metadata and controls
83 lines (71 loc) · 2.85 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
/*
* BioJava development code
*
* This code may be freely distributed and modified under the
* terms of the GNU Lesser General Public Licence. This should
* be distributed with the code. If you do not have a copy,
* see:
*
* http://www.gnu.org/copyleft/lesser.html
*
* Copyright for this code is held jointly by the individual
* authors. These should be listed in @author doc comments.
*
* For more information on the BioJava project and its aims,
* or to join the biojava-l mailing list, visit the home page
* at:
*
* http://www.biojava.org/
*
* Created on Jul 6, 2016
* Author: blivens
*
*/
package org.biojava.http;
import static spark.Spark.get;
import static spark.Spark.port;
import static spark.Spark.staticFileLocation;
import org.biojava.http.compute.CeSymmFastaTransformer;
import org.biojava.http.compute.CeSymmPDBTransformer;
import org.biojava.http.compute.CeSymmTSVTransformer;
import org.biojava.http.compute.JsonTransformer;
import org.biojava.http.routes.CeSymmMMTFRoute;
import org.biojava.http.routes.CeSymmResultRoute;
import org.biojava.http.routes.CeSymmRoute;
import org.biojava.http.routes.MMCIFRoute;
import org.biojava.http.routes.MMTFRoute;
import org.biojava.http.routes.NGLRoute;
import org.biojava.http.routes.PDBRoute;
import org.biojava.nbio.structure.symmetry.internal.CeSymmResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import spark.Request;
import spark.Response;
import spark.template.handlebars.HandlebarsTemplateEngine;
public class ServerMain {
public static Logger logger = LoggerFactory.getLogger(ServerMain.class);
public static void main(String[] args) {
port(8080);
staticFileLocation("/static");
// Document new routes in index.html!
get(BioJavaRoutes.PDB, new PDBRoute());
get(BioJavaRoutes.MMCIF, new MMCIFRoute());
get(BioJavaRoutes.MMTF, new MMTFRoute());
get(BioJavaRoutes.NGL, new NGLRoute(), new HandlebarsTemplateEngine());
get(BioJavaRoutes.CESYMM, new CeSymmRoute("cesymm.html.hbs"), new HandlebarsTemplateEngine());
get(BioJavaRoutes.CESYMM_MULTIPLE, new CeSymmRoute("cesymm_multi.html.hbs"), new HandlebarsTemplateEngine());
get(BioJavaRoutes.CESYMM_JSON, new CeSymmResultRoute(),new JsonTransformer());
get(BioJavaRoutes.CESYMM_PDB, new CeSymmResultRoute() {
@Override public CeSymmResult handle(Request request, Response response) {
CeSymmResult result = super.handle(request, response);
response.header("Content-Type", "chemical/x-pdb");
return result;
};
},new CeSymmPDBTransformer());
get(BioJavaRoutes.CESYMM_MMTF, new CeSymmMMTFRoute());
get(BioJavaRoutes.CESYMM_TSV, new CeSymmResultRoute(),new CeSymmTSVTransformer());
get(BioJavaRoutes.CESYMM_FASTA, new CeSymmResultRoute(),new CeSymmFastaTransformer());
// Gives 500 for me currently -SB, laptop, 2016-08-17
//RouteOverview.enableRouteOverview("/routes");
}
}