-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.go
More file actions
58 lines (47 loc) · 1.44 KB
/
api.go
File metadata and controls
58 lines (47 loc) · 1.44 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package api
import (
"net/http"
"github.com/github-trending/api-service/config"
)
const (
DocumentationURL = "/docs"
RootEndpoint = "/api"
RepositoryEndpoint = "/api/repositories"
)
var Host = config.Get("host")
type hateoas struct {
DocumentationURL string `json:"documentation_url"`
RootEndpoint string `json:"root_endpoint"`
RepositoryURL string `json:"repository_url"`
}
var HATEOAS = hateoas{
DocumentationURL: Host + DocumentationURL,
RootEndpoint: Host + RootEndpoint,
RepositoryURL: Host + RepositoryEndpoint,
}
type ErrorResponse struct {
Message string `json:"message"`
DocumentationURL string `json:"documentation_url"`
}
var ErrorBadRequest = ErrorResponse{
Message: http.StatusText(http.StatusBadRequest),
DocumentationURL: Host + DocumentationURL,
}
var ErrorNotFound = ErrorResponse{
Message: http.StatusText(http.StatusNotFound),
DocumentationURL: Host + DocumentationURL,
}
var ErrorServiceUnavailable = ErrorResponse{
Message: http.StatusText(http.StatusServiceUnavailable),
DocumentationURL: Host + DocumentationURL,
}
type Repository struct {
Title string `json:"title"`
Owner string `json:"owner"`
Name string `json:"name"`
Description string `json:"description"`
Language string `json:""`
Stars int `json:"stars"`
AdditionalStars int `json:"additional_stars"`
URL string `json:"url"`
}