Code Monkey home page Code Monkey logo

s4's Introduction

S4 - Spray Slick Scala Start

Simple, mostly blank project to help you get started with a Spray REST service using Slick as persistence broker.

It's just a start, but you immediately get:

  • Spray

  • Akka

  • Slick

  • Logging

  • Testing

  • File Upload

  • HTTP Basic Authentication

  • A slice of cake

This project is nothing fancy, but tries to put skeleton code at the right places to start building a more serious project.

The cake pattern is used to allow multiple database backend support without code change. This complicates the code a little, but it will be worth it in the long run. For a basic Slick cake pattern example (and where I got some code from) have a look at the MultiDBCakeExample

To get going:

  1. Clone the project

  2. Change into the project directory, type sbt and hit return

  3. Wait for stuff to start up and type test

To run the project as a service:

  1. Have a look at DBConfig.scala to see what database will be used (default PostgreSQL with a database called s4)

  2. Make sure you have PostgreSQL running and update the DBConfig.scala file to include your password.

  3. You can run the project by typing run

  4. Verify that it's running by visiting localhost:8080

  5. Now you can post some json to it (look at the tests for some valid examples)

Simple sample of file upload:

To test the upload function. With s4 running, open another terminal and go into the s4 directory. Once there, excecute the following command:

curl -i -F "[email protected]" http://127.0.0.1:8080/upload

This will upload the sample image 'testpic.png' to the server. The server will save the image to the same directory, but this time it will be called 'test.png'.

Using an IDE:

Both the Scala IDE (Eclipse) project generator and Idea project generator are included in plugins.sbt, so you can type gen-idea or eclipse in the SBT console to generate the project configuration for either of these great IDE's. Personally, I use both: Scala IDE for day-to-day development and it's amazing Scala Worksheet functionality, and Idea for it's superior search and replace.

Contribute:

Pull requests are welcome!

Getting help:

The spray-user forum and slick forum are both the best places to find help on the specific libraries. For questions or suggestions on specific to this project, please visit the S4 group.

Updates:

I will tweet any significant change to the sample project.

Credits:

This example borrows a great deal from examples provided by both the Spray and Slick authors.

Disclaimer: I am hoping this will serve as a nice example to get going, but you are using this code at your own risk.

s4's People

Contributors

byrnedo avatar jacobus avatar

Watchers

 avatar  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.