All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.uqbar.xtrest.api.XTRest.xtend Maven / Gradle / Ivy

There is a newer version: 1.1.4
Show newest version
package org.uqbar.xtrest.api

import org.eclipse.jetty.server.Handler
import org.eclipse.jetty.server.Server
import org.eclipse.jetty.server.handler.HandlerList
import org.eclipse.jetty.server.handler.ResourceHandler

/**
 * Main program class
 * This starts an embedded jetty webserver that will be
 * listening for requests and calling you controllers.
 */
class XTRest {
	public static val RESOURCE_BASE = 'src/main/webapp'
	
	def static start(Class controller, int port) {
		new Server(port) => [
			
			val resource_handler = new ResourceHandler => [
		        directoriesListed = true
		        welcomeFiles = #['index.html']
	    	    resourceBase = RESOURCE_BASE
			]
			
			handler = new HandlerList => [
				setHandlers(#[resource_handler, controller.newInstance])
			]
//			handler = controller.newInstance
			start
			join
		]
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy