Permalink
Browse files

Initial commit, get id works

  • Loading branch information...
mrb committed May 31, 2012
0 parents commit 84ec576c7372c33e19a19e4481060ad4e0a39546
Showing with 73 additions and 0 deletions.
  1. +23 −0 .gitignore
  2. +1 −0 README.md
  3. +48 −0 main.go
  4. +1 −0 main_test.go
@@ -0,0 +1,23 @@
+# Compiled Object files, Static and Dynamic libs (Shared Objects)
+*.o
+*.a
+*.so
+
+# Folders
+_obj
+_test
+
+# Architecture specific extensions/prefixes
+*.[568vq]
+[568vq].out
+
+*.cgo1.go
+*.cgo2.c
+_cgo_defun.c
+_cgo_gotypes.go
+_cgo_export.*
+
+_testmain.go
+
+*.exe
+example/example
@@ -0,0 +1 @@
+## Shoebox
48 main.go
@@ -0,0 +1,48 @@
+package main
+
+import (
+ "github.com/bmizerany/noeq.go"
+ "github.com/bmizerany/pat"
+ "github.com/mrb/riakpbc"
+
+ "fmt"
+ "io"
+ "log"
+ "net/http"
+)
+
+var (
+ riakc *riakpbc.Conn
+ noeqc *noeq.Client
+)
+
+func GetId(w http.ResponseWriter, req *http.Request) {
+ id, _ := noeqc.GenOne()
+ stringId := fmt.Sprintf("%d", id)
+ io.WriteString(w, stringId)
+}
+
+func main() {
+ riakc, err := riakpbc.Dial("127.0.0.1:8087")
+ if err != nil {
+ log.Print(err)
+ }
+
+ log.Print(riakc)
+
+ noeqc, err = noeq.New("", "127.0.0.1:4444")
+ if err != nil {
+ log.Print(err)
+ }
+
+ log.Print(noeqc)
+
+ m := pat.New()
+ m.Get("/id/new", http.HandlerFunc(GetId))
+
+ http.Handle("/", m)
+ err = http.ListenAndServe(":12345", nil)
+ if err != nil {
+ log.Fatal("ListenAndServe: ", err)
+ }
+}
@@ -0,0 +1 @@
+package main

0 comments on commit 84ec576

Please sign in to comment.