func Run(config string) {
	log.Printf("Starting the HTTP server at port %s", config)
	beego.Run(":" + config)
}
Run main function that starts the HTTP server
package httplib
import (
	"encoding/json"
	"fmt"
	"log"
	"strconv"
	"github.com/astaxie/beego"
	typ "github.com/mesos/mr-redis/common/types"
)
type InputData struct {
	Distribution int  
}
type MainController struct {
	beego.Controller
}
func (this *MainController) Get() {
	this.Ctx.WriteString("hello world")
}
func (this *MainController) CreateInstance() {
	var name string
	var capacity, masters, slaves int
	IData := InputData{Distribution: 1}
	name = this.Ctx.Input.Param(":INSTANCENAME")                   
	capacity, _ = strconv.Atoi(this.Ctx.Input.Param(":CAPACITY"))  
	masters, _ = strconv.Atoi(this.Ctx.Input.Param(":MASTERS"))    
	slaves, _ = strconv.Atoi(this.Ctx.Input.Param(":SLAVES"))      
	inData := this.Ctx.Input.CopyBody()
	if len(inData) > 0 {
		err := json.Unmarshal(inData, &IData)
		if err != nil {
			log.Printf("Invalid JSON format along wtih CREATE call IGNORING")
		}
	}
	log.Printf("Instance Name=%s, Capacity=%d, masters=%d, slaves=%d ConfigJson=%v\n", name, capacity, masters, slaves, IData)
	tmpInstance := typ.MemDb.Get(name)
	if tmpInstance == nil {
		tmpInstance = typ.LoadInstance(name)
	}
	if tmpInstance != nil {
		typ.MemDb.Add(name, tmpInstance)
		if tmpInstance.Status == typ.INST_STATUS_DELETED {
			this.Ctx.ResponseWriter.WriteHeader(201)
			this.Ctx.WriteString(fmt.Sprintf("Instance %s already exist, but in deleted state re-creating it", name))
		} else {
			this.Ctx.WriteString(fmt.Sprintf("Instance %s already exist, cannot be created", name))
			return
		}
	}
	instType := typ.INST_TYPE_SINGLE
	if slaves > 0 {
		instType = typ.INST_TYPE_MASTER_SLAVE
	}
	tmpInstance = typ.NewInstance(name, instType, masters, slaves, capacity)
	tmpInstance.Status = typ.INST_STATUS_CREATING
	tmpInstance.DistributionValue = IData.Distribution
	tmpInstance.Sync()
	ok, _ := typ.MemDb.Add(name, tmpInstance)
	if !ok {
		typ.MemDb.Update(name, tmpInstance)
	}
	typ.Cchan <- typ.CreateMaster(tmpInstance)
	this.Ctx.ResponseWriter.WriteHeader(201)
	this.Ctx.WriteString("Request Accepted, Instance will be created.")
}
func (this *MainController) DeleteInstance() {
	var name string
	name = this.Ctx.Input.Param(":INSTANCENAME")  
	tmpInst := typ.MemDb.Get(name)
	if tmpInst == nil {
		tmpInst = typ.LoadInstance(name)
	}
	if tmpInst != nil {
		if tmpInst.Status == typ.INST_STATUS_DELETED {
			this.Ctx.ResponseWriter.WriteHeader(401)
			this.Ctx.WriteString(fmt.Sprintf("Instance %s is already deleted", name))
			return
		}
		var tMsg typ.TaskMsg
		tMsg.P = tmpInst.Procs[tmpInst.Mname]
		tMsg.MSG = typ.TASK_MSG_DESTROY
		log.Printf("Destorying master %v from Instance %v", tMsg.P.ID, tmpInst.Name)
		typ.Dchan <- tMsg
		for _, n := range tmpInst.Snames {
			tMsg.P = tmpInst.Procs[n]
			if tMsg.P != nil {
				log.Printf("Destorying slave %v from Instance %v", tMsg.P.ID, tmpInst.Name)
			} else {
				log.Printf("Destroying Proc of the slave = %v is nil ", n)
			}
			typ.Dchan <- tMsg
		}
	} else {
		this.Ctx.ResponseWriter.WriteHeader(401)
		this.Ctx.WriteString(fmt.Sprintf("Instance %s does not exist, cannot be deleted", name))
		return
	}
	this.Ctx.ResponseWriter.WriteHeader(200)
	this.Ctx.WriteString("Request Placed for destroying")
}
func (this *MainController) Status() {
	var name string
	var inst *typ.Instance
	name = this.Ctx.Input.Param(":INSTANCENAME")  
	inst = typ.MemDb.Get(name)
	if inst == nil {
		inst = typ.LoadInstance(name)
		if inst == nil {
			this.Ctx.ResponseWriter.WriteHeader(501)
			this.Ctx.WriteString(fmt.Sprintf("Instance %s does not exist, error", name))
			return
		}
		typ.MemDb.Add(name, inst)
	}
	this.Ctx.WriteString(inst.ToJson())
}
func (this *MainController) StatusAll() {
	var statusAll []typ.Instance_Json
	if len(typ.MemDb.I) == 0 {
		this.Ctx.WriteString("[]")
		return
	}
	for _, inst := range typ.MemDb.I {
		if inst.Status == typ.INST_STATUS_RUNNING {
			statusAll = append(statusAll, inst.ToJson_Obj())
		}
	}
	statusBytes, err := json.Marshal(statusAll)
	if err != nil {
		this.Ctx.WriteString("STATUSALL: Json Unmarshalling error")
		return
	}
	this.Ctx.WriteString(string(statusBytes))
}
func (this *MainController) UpdateMemory() {
	var name string
	name = this.Ctx.Input.Param(":INSTANCENAME")  
	if !typ.MemDb.IsValid(name) {
		this.Ctx.ResponseWriter.WriteHeader(501)
		this.Ctx.WriteString(fmt.Sprintf("Instance %s already exist, cannot be create", name))
		return
	}
	this.Ctx.WriteString("Upgrading the instance")
}
func (this *MainController) UpdateSlaves() {
	var name string
	name = this.Ctx.Input.Param(":INSTANCENAME")  
	if typ.MemDb.IsValid(name) {
		this.Ctx.WriteString(fmt.Sprintf("Instance %s already exist, cannot be create", name))
		return
	}
	this.Ctx.WriteString("Upgrading the instance slaves")
}