summary refs log blame commit diff stats
path: root/main.go
blob: d8a06141e99d944fa295ae4a1c104214fa712188 (plain) (tree)
1
2
3
4
5
6
7
8
9
10




                  

                                     
                                

 

                     
             
                                               
 
                               
 
                                          




                                                                                                                                    
 
                                                                                 
 
package main

import (
	"log"
	"net/http"

	"github.com/gorilla/handlers"
	"github.com/gorilla/mux"
)

const getwtxt = "0.1"

func main() {
	log.Printf("getwtxt " + getwtxt + "\n")

	serv := mux.NewRouter()

	serv.HandleFunc("/", indexHandler)
	serv.HandleFunc("/{api:(?:api|api/)}", apiBaseHandler)
	serv.HandleFunc("/api/{format:(?:plain|plain/)}", apiFormatHandler)
	serv.HandleFunc("/api/{format:(?:plain)}/{endpoint:(?:mentions|mentions/|users|users/|tweets|tweets/)}", apiEndpointHandler)
	serv.HandleFunc("/api/{format:(?:plain)}/tags/{tags:[a-zA-Z0-9]+}", apiTagsHandler)
	serv.HandleFunc("/api/{format:(?:plain)}/{tagpathfixer:(?:tags|tags/)}", apiTagsBaseHandler)

	log.Fatalln(http.ListenAndServe(":8080", handlers.CompressHandler(serv)))
}