-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
32 lines (27 loc) · 735 Bytes
/
main.go
File metadata and controls
32 lines (27 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package main
import (
"log"
"net/http"
"time"
"github.com/gorilla/mux"
"github.com/joho/godotenv"
)
func main() {
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
r := mux.NewRouter()
r.HandleFunc("/search-tweets/{query}", SearchTweets).Methods("GET")
r.HandleFunc("/users/{user}", SearchUsers).Methods("GET")
r.HandleFunc("/trends/{woeid}", GetRecentTrends).Methods("GET")
r.HandleFunc("/timeline/{name}", GetUserTimeline).Methods("GET")
r.HandleFunc("/stream/{query}", StreamUserTweets).Methods("GET")
srv := &http.Server{
Handler: r,
Addr: "127.0.0.1:8000",
WriteTimeout: 15 * time.Second,
ReadTimeout: 15 * time.Second,
}
log.Fatal(srv.ListenAndServe())
}