all of these are prepended by blog
posts.GET("/post/:id", getPost) // this gets the post by the actual ID
posts.GET("/search/tag/:id", getByTag)
posts.GET("/search/string/:id", getByString)
posts.GET("/posts", getPosts) // this supports the query string offset, and number
// offset: specifies the number of recent blog posts to skip. Default 0
// number: upper limit on the number of blog posts to return. Default 5
// Eg) to get the most recent 5 posts
// GET http://this-blog-server.com:8049/blog/posts
// to get the next 10 most recent posts
// GET http://this-blog-server.com:8049/blog/posts?offset=5&number=10
posts.GET("/number, getPostCount) // number of posts
posts.PUT("/", putPost)
posts.DELETE("/:id", deletePost)
A post is a json object with the following structure
type Post struct {
ID int `json:"id"`
Title string `json:"title"`
Author string `json:"author"`
Post string `json:"post"`
Timestamp uint64 `json:"timestamp"`
Tags []string `json:"tags"`
}
- Install go
- Get files with
go get github.com/jacobrec/spearserver
- Install mysql server
- In mysql create a database and a user and grant that user all privaliges on that database
- Place .passwords file in the src/github.com/jacobrec/spearserver directory
- From the src/github.com/jacobrec/spearserver directory build the project with
go build
- run with -setup from the src/github.com/jacobrec/spearserver directory
- run normally from the src/github.com/jacobrec/spearserver directory to start webserver
should have the name .passwords file should be 3 lines and read like this. the username, password, and database refer to the sql database and user you just created
username
password
database
This file needs to be placed in the directory of which you run the program from