This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sbt._ | |
class BowlerProject(info: ProjectInfo) extends DefaultWebProject(info){ | |
val bowler = "org.bowlerframework" %% "core" % "0.5.1" | |
val slf4jVersion = "1.6.0" | |
val sfl4jnop = "org.slf4j" % "slf4j-nop" % slf4jVersion % "runtime" | |
// allows you to use an embedded/in-JVM jetty-server to run unit-tests. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This goes into your <repositories>-section of your pom.xml: | |
<repository> | |
<id>nexus</id> | |
<name>Nexus Repository</name> | |
<url>https://oss.sonatype.org/content/repositories/releases</url> | |
</repository> | |
This goes into your <dependencies>-section: | |
<dependency> | |
<groupId>org.bowlerframework</groupId> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.bowlerframework.examples | |
import org.bowlerframework.model.Validations | |
import org.bowlerframework.view.{Renderable, ViewPath} | |
import org.bowlerframework.view.scalate.DefaultLayout | |
import org.bowlerframework._ | |
import controller.{FunctionNameConventionRoutes, Controller, LayoutAware} | |
/** | |
* Our main application controller, showing a simple CRUD interface. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" | |
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" | |
version="2.5"> | |
<display-name>Bowler Sample</display-name> | |
<filter> | |
<filter-name>examples</filter-name> | |
<filter-class>org.bowlerframework.http.BowlerFilter</filter-class> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package bowlerquickstart | |
import org.bowlerframework.view.scalate._ | |
/** | |
* This class acts as the starting point and bootstrap point for our application | |
*/ | |
class Bootstrap{ | |
// parent layout | |
val parentLayout = DefaultLayout("default") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyController extends Controller{ | |
// responds to GET requests at /widgets/ | |
get("/widgets/")((request, response) => { | |
..code goes here.. | |
}) | |
// responds to GET requests at /widgets/[someId], where | |
// ":id" will be mapped to a named request parameter "id" | |
get("/widgets/:id")((request, response) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get("/say/*/to/*")((request, response) => { | |
..code goes here.. | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get("""^\/f(.*)/b(.*)""".r)((request, response) => { | |
.. code here .. | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class Widget(id: Long, name: String, priceInPence: Int) | |
class WidgetController extends Controller with Renderable with FunctionNameConventionRoutes{ | |
def `GET /showAWidget` = { | |
val myWidget = Widget(1, "My Widget", 1000) | |
render(myWidget) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{#widget}} | |
<b>Id</b><br/> | |
{{id}}<br/> | |
<b>Name</b><br/> | |
{{name}}<br/> | |
<b>Price</b><br/> | |
{{priceInPence}}<br/> | |
{{/widget}} |
OlderNewer