Thanks to visit codestin.com
Credit goes to github.com

Skip to content
/ socko Public
forked from mashupbots/socko

A Scala web server powered by Netty networking and AKKA processing.

License

Notifications You must be signed in to change notification settings

lucevers/socko

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

159 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 3.7 Indigo with Scala IDE nightly build

  • We are currently using Scala 2.9.1 and JDK7. You can also use 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

About

A Scala web server powered by Netty networking and AKKA processing.

Resources

License

Stars

Watchers

Forks

Packages

No packages published