Giter Club home page Giter Club logo

socko's Introduction

SOCKO

Socko is an embedded Scala web server powered by Netty networking and Akka processing.

Please see our web site for documentaiton and more information

A quick example

    object HelloApp extends Logger {
      //
      // STEP #1 - Define Actors and Start Akka
      // See `HelloHandler`
      //
      val actorSystem = ActorSystem("HelloExampleActorSystem")

      //
      // STEP #2 - Define Routes
      // Dispatch all HTTP GET events to a newly instanced `HelloHandler` actor for processing.
      // `HelloHandler` will `stop()` itself after processing each request.
      //
      val routes = Routes({
        case GET(request) => {
          actorSystem.actorOf(Props[HelloHandler]) ! request
        }
      })

      //
      // STEP #3 - Start and Stop Socko Web Server
      //
      def main(args: Array[String]) {
        val webServer = new WebServer(WebServerConfig(), routes, actorSystem)
        webServer.start()

        Runtime.getRuntime.addShutdownHook(new Thread {
          override def run { webServer.stop() }
        })

        System.out.println("Open your browser and navigate to http://localhost:8888")
      }
    }

    /**
     * Hello processor writes a greeting and stops.
     */
    class HelloHandler extends Actor {
      def receive = {
        case event: HttpRequestEvent =>
          event.response.write("Hello from Socko (" + new Date().toString + ")")
          context.stop(self)
      }
    }

Editing the Source Code

  • We are currently using Eclipse Juno with Scala IDE 3.0

  • We are currently using Scala 2.10.1 and JDK7. You will need JDK7 to build. The core and rest projects will be compiled for use with JDK6 but SPDY will not be supported.

  • Generate eclipse project files: sbt eclispse

  • Start Eclipse

  • From the top menu, select File | Import

    • Select General | Existing Projects into Workspace.
    • Click Next.
    • Select the socko source code directory as the root
    • Should see socko-examples and socko-webserver under Projects
    • Click Finish
  • To run the scalatest unit test cases, just right click on a test class file and select Run As JUnit Test.

Getting Help

If you have a question or need help, please open a ticket in our [Issues Register] (https://github.com/mashupbots/socko/issues).

Links

socko's People

Contributors

chenweiyj avatar gnawux avatar leifwickland avatar lightningdb avatar navicore avatar normanmaurer avatar skylve avatar thirstycrow avatar veebs avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.