Documentation
¶
Index ¶
Constants ¶
View Source
const ( // UsersURL is the URL path to manage Users UsersURL = "/" + apiVersion + "/users" // PostsURL is the URL path to manage Posts PostsURL = "/" + apiVersion + "/posts" // FollowURL is the URL path to perform following/unfollowing actions FollowURL = "/" + apiVersion + "/follow" // FollowersURL is the URL path to manage your followers FollowersURL = "/" + apiVersion + "/followers" // FollowingURL is the URL path to manage users you follow FollowingURL = "/" + apiVersion + "/following" )
Variables ¶
This section is empty.
Functions ¶
func BasicCredentialsExtractor ¶
BasicCredentialsExtractor extract credentials from basic auth header
func WriteResponse ¶
func WriteResponse(w http.ResponseWriter, status int, payload interface{})
WriteResponse writes a payload to the provided writer
Types ¶
type API ¶
type API struct {
// Controllers contains the registered controllers
Controllers []Controller
// Filters contains registered filters for this API
Filters []Filter
}
API is the primary point for REST API registration
type Controller ¶
type Controller interface {
// Routes returns the set of routes for this controller
Routes() []Route
}
Controller is an entity that wraps a set of HTTP Routes
type CredentialsExtractor ¶
CredentialsExtractor is a generic interface for extracting credentials from different auth mechanism
type CredentialsExtractorFunc ¶
CredentialsExtractorFunc is a wrapper of CredentialsExtractor so a normal function could be used as CredentialsExtractor
type ErrorResponse ¶
type ErrorResponse struct {
Error string `json:"error"`
}
ErrorResponse defines an error response payload
type Filter ¶
type Filter interface {
// Filter filters http request on some conditions
Filter(r *http.Request) (int, error)
// MatchingEndpoints returns all the endpoints that the filter should be attached before.
MatchingEndpoints() []Endpoint
}
Filter interface provides an interface for filtering http requests on some conditions
type Route ¶
type Route struct {
// Endpoint is the combination of Path and HTTP Method for the specified route
Endpoint Endpoint
// Handler is the function that should handle incoming requests for this endpoint
Handler http.HandlerFunc
}
Route is a mapping between an Endpoint and a REST API Handler
Click to show internal directories.
Click to hide internal directories.