Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added /raw/ + /assets/ to the routing

  • Loading branch information...
commit 6eff034af930ddea4d0ac7e27629375e75c7a2a1 1 parent 93460d6
Jared Wilkening jaredwilkening authored
2  README.md
View
@@ -1,4 +1,4 @@
-![Shock](http://github.com/jaredwilkening/Shock/raw/master/misc/shock_logo.png)
+![Shock](http://github.com/jaredwilkening/Shock/raw/master/site/assets/img/shock_logo.png)
=====
About:
2  conf/conf.go
View
@@ -2,6 +2,7 @@ package conf
import (
"flag"
+ "os"
)
// Command line options
@@ -10,6 +11,7 @@ var (
DATAROOT = flag.String("data", "", "data directory to store on disk files")
MONGODB = flag.String("mongodb", "localhost", "hostname(s) of mongodb")
SECRETKEY = flag.String("secretkey", "supersupersecret", "secret key")
+ SITEPATH = os.ExpandEnv("$GOPATH") + "/src/github.com/MG-RAST/Shock/site"
)
func init() {
BIN  misc/shock_logo.png
View
Deleted file not rendered
3  shock-server/shock-server.go
View
@@ -8,8 +8,11 @@ import (
func main() {
goweb.ConfigureDefaultFormatters()
+ goweb.MapFunc("/raw", RawDir)
+ goweb.MapFunc("/assets", AssetsDir)
goweb.MapRest("/node", new(NodeController))
goweb.MapRest("/user", new(UserController))
+ goweb.MapFunc("*", Site)
fmt.Printf("Shock (port:%d, dataroot:%q, mongodb_host:%q, secretkey:%q)... starting\n", *conf.PORT, *conf.DATAROOT, *conf.MONGODB, *conf.SECRETKEY)
goweb.ListenAndServe(":" + fmt.Sprintf("%d", *conf.PORT))
}
16 shock-server/util.go
View
@@ -9,6 +9,7 @@ import (
"fmt"
"github.com/MG-RAST/Shock/conf"
ds "github.com/MG-RAST/Shock/datastore"
+ "github.com/MG-RAST/Shock/goweb"
"github.com/MG-RAST/Shock/user"
"io"
"math/rand"
@@ -146,6 +147,21 @@ func ParseMultipartForm(r *http.Request) (params map[string]string, files ds.For
return
}
+func Site(cx *goweb.Context) {
+ LogRequest(cx.Request)
+ http.ServeFile(cx.ResponseWriter, cx.Request, conf.SITEPATH+"/pages/main.html")
+}
+
+func RawDir(cx *goweb.Context) {
+ LogRequest(cx.Request)
+ http.ServeFile(cx.ResponseWriter, cx.Request, fmt.Sprintf("%s%s", *conf.DATAROOT, cx.Request.URL.Path))
+}
+
+func AssetsDir(cx *goweb.Context) {
+ LogRequest(cx.Request)
+ http.ServeFile(cx.ResponseWriter, cx.Request, conf.SITEPATH+cx.Request.URL.Path)
+}
+
func LogRequest(req *http.Request) {
host, _, _ := net.SplitHostPort(req.RemoteAddr)
// failed attempt to get the host in ipv4
Please sign in to comment.
Something went wrong with that request. Please try again.