# play-mini **Repository Path**: mefaso/play-mini ## Basic Information - **Project Name**: play-mini - **Description**: play-mini官方不更新 只好自己兼容 - **Primary Language**: Scala - **License**: Not specified - **Default Branch**: mine - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2014-03-25 - **Last Updated**: 2024-11-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README Play2 Mini Project ================== 正式环境部署 ---------- 不推荐使用`sbt-assembly`打包,需要解决包冲突。可以在主目录下直接`nohup java ${各种java参数} -jar sbt-launch.jar run`,但默认的是 测试Mod。另在ubuntu server下,会报`Bad File descriptor`错误(具体原因自行google),然后挂掉。 推荐 --- 推荐使用 `sbt stage`命令。 1.运行sbt clean compile stage 打出包,包打到 ${project home}/target/universal/stage下 2.cd ${project home}/target/universal/stage/bin 3.修改timer.bash中的 `declare -r app_mainclass="play.core.server.NettyServer"` =>`declare -r app_mainclass="server.Play"` 4.执行`bash timer -Dconfig.file=${a file end with .conf}` 即可,注意必须添加`-Dconfig.file`参数(即使指定的文件为空文件也可以),否则会报`Configuration error`异常。 Play2 Mini Project provides REST API on top of `Play2 `_ Scala ----- In the global package name space:: object Global extends com.typesafe.play.mini.Setup(com.example.App) and then in your own package:: object App extends com.typesafe.play.mini.Application { def route = { case GET(Path("/coco")) & QueryString(qs) => Action{ val o = QueryString(qs,"foo").getOrElse("noh") Ok(

It works!, query String {o}

).as("text/html") } case GET(Path("/flowers")) => Action{ Ok(

It works for flowers!

).as("text/html") } } } The API is based on the always awesome `Unfiltered `_ library. Extending the Extractor based approach with regex or simple matching is possible too:: object App extends com.typesafe.play.mini.Application { def route = Routes( Through("/people/(.*)".r) {groups: List[String] => Action{ val id :: Nil = groups Ok(

It works with regex!, id: {id}

).as("text/html") } }, {case GET(Path("/coco")) & QueryString(qs) => Action{ request => println(request.body) println(play.api.Play.current) val result = QueryString(qs,"foo").getOrElse("noh") Ok(

It works!, query String {result}

).as("text/html") } }, Through("/flowers/id/") {groups: List[String] => Action{ val id :: Nil = groups Ok(

It works with simple startsWith! - id: {id}

).as("text/html") } }, Through("/cars/id/") {groups: List[String] => ActorAction[String](myActor, Car) {reply: String => Ok(reply) } } ) } for more information about extractors, regex and Routes, please `see `_ Other than this, there are many useful utilities available at your fingertip, take a look at the official guide of `Play for Scala Developers `_ Java ---- In the global package name space:: //Global.scala object Global extends com.typesafe.play.mini.SetupJavaApplicationFor[com.example.App] and then in your own package:: //com/example/App.java package com.example; public class App extends Controller { @URL("/hello") public static Result index() { return ok("It works as text!"); } @URL("/foo/*/name/*") public static Result index2(String foo, String name) { response().setContentType("/text/html"); return ok("It works:"+ foo +" "+name); } } Other than this, there are many useful utilities available at your fingertip, take a look at `Play Java Utils `_ and `Async processing with Play `_ See sample apps for more examples. G8 Project templates -------------------- `G8 `_ project templates are available as well. java:: g8 typesafehub/play-mini-java.g8 scala:: g8 typesafehub/play-mini-scala.g8 Licence ------- The code is licensed under Apache 2 license:: This software is licensed under the Apache 2 license, quoted below. Copyright 2011 Typesafe (http://www.typesafe.com). Licensed under the Apache License, Version 2.0 (the "License"); you may not use this project except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.