All Projects → skinny-framework → skinny-micro

skinny-framework / skinny-micro

Licence: other
🎤 Micro Web framework to build Servlet applications in Scala, the core part of Skinny Framework 2

Programming Languages

scala
5932 projects
java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to skinny-micro

Scalatra
Tiny Scala high-performance, async web framework, inspired by Sinatra
Stars: ✭ 2,529 (+4336.84%)
Mutual labels:  web-framework, jetty, scalate
Dropwizard
A damn simple library for building production-ready RESTful web services.
Stars: ✭ 8,078 (+14071.93%)
Mutual labels:  web-framework, jetty
Javalin
A simple and modern Java and Kotlin web framework
Stars: ✭ 5,184 (+8994.74%)
Mutual labels:  web-framework, jetty
kafka-serde-scala
Implicitly converts typeclass encoders to kafka Serializer, Deserializer, Serde.
Stars: ✭ 52 (-8.77%)
Mutual labels:  jackson, json4s
HongsCORE
Hong's Common Object Requesting Engine
Stars: ✭ 49 (-14.04%)
Mutual labels:  jetty
Polyel-Framework
⚡️ Voltis Core: A PHP framework based on Swoole from the ground up
Stars: ✭ 22 (-61.4%)
Mutual labels:  web-framework
jersey-jwt-springsecurity
Example of REST API with JWT authentication using Spring Boot, Spring Security, Jersey and Jackson.
Stars: ✭ 44 (-22.81%)
Mutual labels:  jackson
mif
MIF is a C++11 web-application framework designed for the backend micro-service development
Stars: ✭ 42 (-26.32%)
Mutual labels:  web-framework
id-mask
IDMask is a Java library for masking internal ids (e.g. from your DB) when they need to be published to hide their actual value and to prevent forging. It has support optional randomisation has a wide support for various Java types including long, UUID and BigInteger. This library bases its security on strong cryptographic primitives.
Stars: ✭ 39 (-31.58%)
Mutual labels:  jackson
reactive-extension
Simple webfilter tracking extension based on Webflux, default use the Jetty container.
Stars: ✭ 15 (-73.68%)
Mutual labels:  jetty
docker-jetty
Formerly the location of the Docker official image for Jetty
Stars: ✭ 47 (-17.54%)
Mutual labels:  jetty
koa
A golang framework like koa.js and has the best performance with net/http.
Stars: ✭ 30 (-47.37%)
Mutual labels:  web-framework
alef-component
Alef Component for Modern Web Apps.
Stars: ✭ 46 (-19.3%)
Mutual labels:  web-framework
stirfry
StirFry is a self contained and lightweight web framework for nodejs
Stars: ✭ 24 (-57.89%)
Mutual labels:  web-framework
jackson-dynamic-filter
An easy way to determine filters dynamically using Jackson
Stars: ✭ 35 (-38.6%)
Mutual labels:  jackson
kafka-serialization
Lego bricks to build Apache Kafka serializers and deserializers
Stars: ✭ 122 (+114.04%)
Mutual labels:  json4s
endpoints
Lightweight REST api backend framework that automatically maps urls to python modules and classes
Stars: ✭ 30 (-47.37%)
Mutual labels:  web-framework
winstone
Patched winstone used in Jenkins
Stars: ✭ 63 (+10.53%)
Mutual labels:  jetty
ncms
Java CMS engine. Host and develop multiple websites inside a single instance through the GUI and benefit from features like A/B testing, affiliate tracking tools, and a high performance template engine with CSS stylesheets processing & scripts minification.
Stars: ✭ 32 (-43.86%)
Mutual labels:  web-framework
recurse
Qt based micro web framework with middleware design
Stars: ✭ 19 (-66.67%)
Mutual labels:  web-framework

Skinny Micro Maven Central CI Build

Skinny Micro is at once a micro Web framework to build Servlet applications in Scala and the core part of Skinny Framework.

Skinny Micro started as a fork of Scalatra. After that, many improvements have been made to be safer and more efficient when working with Scala Future values upon it.

Basically, Skinny Micro's DSLs are source compatible with Scalatra 2.3's ones. But names of base traits and packages are mostly renamed and the structure of internal modules are re-designed.

Getting Started

Taking a look at skinny-micro-heroku-example first would be helpful to understand what you need to do. samples and scalas-samples in this repository are also worth looking at.

Library Dependencies

When you start new sbt project, add the following dependencies:

lazy val skinnyMicroVersion = "2.0.+"

libraryDependencies ++= Seq(
  // micro Web framework
  "org.skinny-framework" %% "skinny-micro"             % skinnyMicroVersion,
  // jackson integration
  "org.skinny-framework" %% "skinny-micro-jackson"     % skinnyMicroVersion,
  "org.skinny-framework" %% "skinny-micro-jackson-xml" % skinnyMicroVersion,
  // json4s integration
  "org.skinny-framework" %% "skinny-micro-json4s"      % skinnyMicroVersion,
  // Scalate integration
  "org.skinny-framework" %% "skinny-micro-scalate"     % skinnyMicroVersion,
  // Standalone Web server (Jetty 9.4 / Servlet 3.1)
  "org.skinny-framework" %% "skinny-micro-server"      % skinnyMicroVersion
)

Minimum Examples

We'd love to show you some simple but working examples briefly.

Please also see more examples under samples and scalas-samples.

Simple Application

The following is a minimum Servlet example. skinny.micro.SkinnyListener initializes Skinny Micro's environment.

As same as Scalatra, _root_.Bootstrap class (instead of _root_.ScalatraBootstrap for Scalatra) is detected by default. If you'd like to change the name of the Bootstrap class, it's also possible by specifying with Servlet's init parameter.

Also take a look at sbt-servlet-plugin. The plugin will help you much when building Servlet applications in Scala.

See samples for more examples.

src/main/scala/app.scala

import javax.servlet._
import skinny.micro._

object Hello extends WebApp {
  get("/say-hello") {
    s"Hello, ${params.getOrElse("name", "Anonymous")}!\n"
  }
}

class Bootstrap extends LifeCycle {
  override def init(ctx: ServletContext) {
    Hello.mount(ctx)
  }
}

src/main/webapp/WEB-INF/web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">
    <listener>
        <listener-class>skinny.micro.SkinnyListener</listener-class>
    </listener>
</web-app>

Async Native Application

Skinny Micro newly privides original base traits that named as AsyncWebApp (AsyncSkinnyMicorFilter) and AsyncSingleWebApp (AsyncSkinnyMicroServlet).

They are natively suitable for building Future-wired async operations. You will no longer unwantedly feel stressed when working with Future-wired operations.

case class Message(id: Long, text: String)

object Messages {
  def search(keyword: Option[String])(implicit ctx: ExecutionContext): Future[Seq[Message]]
}

object AsyncMessagesApp extends AsyncWebApp with JSONSupport {

  post("/messages/search") { implicit ctx =>
    // You don't need to explicitly wrap results with AsyncResult
    // Of course, doing so is also fine
    Messages.search(params.get("keyword"))
      .map(ms => Ok(toJSONString(ms))) // returns Future[ActionResult]
  }
}

Scalas Example

By using scalas, script runnner from sbt, you can easily run small Scala applications.

http://www.scala-sbt.org/0.13/docs/Scripts.html

#!/usr/bin/env scalas
// or ./scalas app.scala
/***
scalaVersion := "2.12.10"
libraryDependencies += "org.skinny-framework" %% "skinny-micro-server" % "2.0.+"
*/
import skinny.micro._
object HelloApp extends WebApp {
  get("/say-hello") {
    s"Hello, ${params.getOrElse("name", "Anonymous")}!\n"
  }
}
WebServer.mount(HelloApp).port(4567).start()

println
println("Try: curl -v 'localhost:4567/say-hello?name=Martin'")
println

Other Examples

More working examples are available under samples and scalas-samples.

License

(The BSD 2-Clause License)

Copyright (c) Alan Dipert

Copyright (c) skinny-framework.org

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].