Browse Source

stubbed out http handlers

bmallred 9 years ago
parent
commit
b08108da8b
4 changed files with 43 additions and 1 deletions
  1. 10 0
      handlers/blog.go
  2. 10 0
      handlers/content.go
  3. 10 0
      handlers/default.go
  4. 13 1
      main.go

+ 10 - 0
handlers/blog.go

@ -0,0 +1,10 @@
1
package handlers
2
3
import (
4
	"fmt"
5
	"net/http"
6
)
7
8
func BlogHandler(w http.ResponseWriter, r *http.Request) {
9
	fmt.Fprintf(w, "Blog")
10
}

+ 10 - 0
handlers/content.go

@ -0,0 +1,10 @@
1
package handlers
2
3
import (
4
	"fmt"
5
	"net/http"
6
)
7
8
func ContentHandler(w http.ResponseWriter, r *http.Request) {
9
	fmt.Fprintf(w, "Content")
10
}

+ 10 - 0
handlers/default.go

@ -0,0 +1,10 @@
1
package handlers
2
3
import (
4
	"fmt"
5
	"net/http"
6
)
7
8
func DefaultHandler(w http.ResponseWriter, r *http.Request) {
9
	fmt.Fprintf(w, "Default")
10
}

+ 13 - 1
main.go

@ -3,6 +3,10 @@ package main
3 3
import (
4 4
	"log"
5 5
	"net/http"
6
	"time"
7
8
	"code.revolvingcow.com/revolvingcow/loop/handlers"
9
	"github.com/gorilla/mux"
6 10
)
7 11
8 12
const (
@ -11,9 +15,17 @@ const (
11 15
12 16
func main() {
13 17
	log.Print("Configuring environment...")
18
	time.Local = time.UTC
14 19
	ConfigureEnvironment()
15 20
16
	//http.HandleFunc("/", DefaultHandler)
21
	r := mux.NewRouter().StrictSlash(false)
22
	r.HandleFunc("/", handlers.DefaultHandler)
23
24
	content := r.PathPrefix("/{username}/content").Subrouter()
25
	content.Methods("GET").HandlerFunc(handlers.ContentHandler)
26
27
	blog := r.PathPrefix("/{username}/blog").Subrouter()
28
	blog.Methods("GET").HandlerFunc(handlers.BlogHandler)
17 29
18 30
	log.Fatal(http.ListenAndServe(address(), nil))
19 31
}