Scala HTTP Server pt 3 – Request case class

Ok, this is another example of a Case class and, as this is all that’s in this post I’ll attempt some further explanation of this nice feature of Scala.

First, here is the class:

package com.vff.scalahttp

case class Request(method:String, resource:String)

Now, here is the Java equivalent:

package com.vff.scalahttp;

public class Request {

  private String method;
  private String resource;

  public Request(final String method, final String resource) {
    this.method = method;
    this.resource = resource;

  public String getMethod() {
    return method;

  public String getResource() {
    return resource;

A case class is a nice construct I typically use for holding data in an immutable way.
Here is the ‘official’ definition:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s