NodeTwitterAPI

package module
v0.0.0-...-aadd961 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2017 License: GPL-2.0 Imports: 7 Imported by: 0

README

node-twitter-api

Node Twitter API written with Go and MongoDB

The database and the model is based from this project Node Twitter

In order to use it, follow this example

package main

import (
	"fmt"
	"log"
	"net/http"
	"os"

	NodeTwitterAPI "github.com/vinitkumar/node-twitter-api"
)

func main() {
	port := os.Getenv("PORT")
	if port == "" {
		log.Fatal("$PORT must be set")
	}
	http.HandleFunc("/", NodeTwitterAPI.BaseHandler)
	http.HandleFunc("/currentuser", NodeTwitterAPI.UserHandler)
	http.HandleFunc("/users", NodeTwitterAPI.UsersHandler)
	http.HandleFunc("/tweet", NodeTwitterAPI.TweetHandler)
	http.HandleFunc("/tweets", NodeTwitterAPI.TweetsHandler)
	http.HandleFunc("/analytic", NodeTwitterAPI.AnalyticHandler)
	http.HandleFunc("/analytics", NodeTwitterAPI.AnalyticsHandler)
	fmt.Println("Running the server on localhost" + port)

	http.ListenAndServe(":"+port, nil)
}

Documentation

Godoc: https://godoc.org/github.com/vinitkumar/node-twitter-api

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnalyticHandler

func AnalyticHandler(w http.ResponseWriter, r *http.Request)

AnalyticHandler : Return one analytic entry from the database.

func AnalyticsHandler

func AnalyticsHandler(w http.ResponseWriter, r *http.Request)

AnalyticsHandler : Returns list of all analytics in the database.

func BaseHandler

func BaseHandler(w http.ResponseWriter, r *http.Request)

BaseHandler Show a landing page with links of the APIs.

func TweetHandler

func TweetHandler(w http.ResponseWriter, r *http.Request)

TweetHandler : Returns tweet by an user in the database.

func TweetsHandler

func TweetsHandler(w http.ResponseWriter, r *http.Request)

TweetsHandler : Returns list of all tweets in the database.

func UserHandler

func UserHandler(w http.ResponseWriter, r *http.Request)

UserHandler : Returns the current user of the session.

func UsersHandler

func UsersHandler(w http.ResponseWriter, r *http.Request)

UsersHandler : Returns list of all users in the database.

Types

type Analytic

type Analytic struct {
	ID   bson.ObjectId `bson:"_id,omitempty"`
	IP   string
	User bson.ObjectId
	URL  string
}

Analytic struct

type Tweet

type Tweet struct {
	ID   bson.ObjectId `bson:"_id,omitempty"`
	Body string
	User bson.ObjectId
}

Tweet Struct

type User

type User struct {
	ID       bson.ObjectId `bson:"_id,omitempty"`
	Name     string
	Username string
	Email    string
	Provider string
}

User struct

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL