Compare commits
8 Commits
10dd431e70
...
chart
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7d5af4c2eb | ||
|
|
e341aca84e | ||
|
|
1b450c08a2 | ||
|
|
3a076bbf78 | ||
|
|
acd9b1611c | ||
|
|
24fd211a43 | ||
|
|
f23ceea934 | ||
|
|
0c810e4f92 |
20
.drone.yml
Normal file
20
.drone.yml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
type: docker
|
||||||
|
kind: pipeline
|
||||||
|
name: unit
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: build
|
||||||
|
image: golang
|
||||||
|
commands:
|
||||||
|
- go test
|
||||||
|
- go build
|
||||||
|
|
||||||
|
- name: publish
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
username:
|
||||||
|
from_secret: docker-user
|
||||||
|
password:
|
||||||
|
from_secret: docker-pw
|
||||||
|
repo:
|
||||||
|
from_secret: docker-repo
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||||
*.out
|
*.out
|
||||||
|
oc-discovery
|
||||||
|
swagger/*
|
||||||
|
|
||||||
# Dependency directories (remove the comment below to include it)
|
# Dependency directories (remove the comment below to include it)
|
||||||
# vendor/
|
# vendor/
|
||||||
|
|||||||
10
.vscode/launch.json
vendored
10
.vscode/launch.json
vendored
@@ -3,5 +3,13 @@
|
|||||||
// Pointez pour afficher la description des attributs existants.
|
// Pointez pour afficher la description des attributs existants.
|
||||||
// Pour plus d'informations, visitez : https://go.microsoft.com/fwlink/?linkid=830387
|
// Pour plus d'informations, visitez : https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": []
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Launch Package",
|
||||||
|
"type": "go",
|
||||||
|
"request": "launch",
|
||||||
|
"mode": "auto",
|
||||||
|
"program": "main.go"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
31
Dockerfile
Normal file
31
Dockerfile
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
FROM golang:alpine as builder
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN apk add git
|
||||||
|
|
||||||
|
RUN go get github.com/beego/bee/v2 && go install github.com/beego/bee/v2@master
|
||||||
|
|
||||||
|
RUN timeout 15 bee run -gendoc=true -downdoc=true -runmode=dev || :
|
||||||
|
|
||||||
|
RUN sed -i 's/http:\/\/127.0.0.1:8080\/swagger\/swagger.json/swagger.json/g' swagger/index.html
|
||||||
|
|
||||||
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" .
|
||||||
|
|
||||||
|
RUN ls /app
|
||||||
|
|
||||||
|
FROM scratch
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY --from=builder /app/oc-discovery /usr/bin/
|
||||||
|
COPY --from=builder /app/swagger /app/swagger
|
||||||
|
COPY peers.json /app/
|
||||||
|
COPY identity.json /app/
|
||||||
|
COPY docker_discovery.json /etc/oc/discovery.json
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
ENTRYPOINT ["oc-discovery"]
|
||||||
10
README.md
10
README.md
@@ -1,10 +1,16 @@
|
|||||||
# oc-discovery OpenCloud discovery service.
|
# oc-discovery OpenCloud discovery service.
|
||||||
|
|
||||||
Can feed from file/IPFS/...
|
Manages a local database
|
||||||
|
|
||||||
Manages a local database and check hosts availability
|
Can feed from file/IPFS/...
|
||||||
|
Stores data in Redis, and Zinq for ranked queries.
|
||||||
|
|
||||||
To build :
|
To build :
|
||||||
|
|
||||||
bee generate routers
|
bee generate routers
|
||||||
bee run -gendoc=true -downdoc=true
|
bee run -gendoc=true -downdoc=true
|
||||||
|
|
||||||
|
If default Swagger page is displayed instead of tyour api, change url in swagger/index.html file to :
|
||||||
|
|
||||||
|
url: "swagger.json"
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,2 @@
|
|||||||
appname = oc-discovery
|
appname = oc-discovery
|
||||||
httpport = 8080
|
|
||||||
runmode = dev
|
|
||||||
autorender = false
|
|
||||||
copyrequestbody = true
|
|
||||||
EnableDocs = true
|
|
||||||
sqlconn =
|
|
||||||
|
|||||||
@@ -15,14 +15,18 @@ type IdentityController struct {
|
|||||||
// @Title CreateIdentity
|
// @Title CreateIdentity
|
||||||
// @Description create identitys
|
// @Description create identitys
|
||||||
// @Param body body models.Identity true "body for identity content"
|
// @Param body body models.Identity true "body for identity content"
|
||||||
// @Success 200 {int} models.Identity.Id
|
// @Success 200 {result} "ok" or error
|
||||||
// @Failure 403 body is empty
|
// @Failure 403 body is empty
|
||||||
// @router / [post]
|
// @router / [post]
|
||||||
func (u *IdentityController) Post() {
|
func (u *IdentityController) Post() {
|
||||||
var identity models.Identity
|
var identity models.Identity
|
||||||
json.Unmarshal(u.Ctx.Input.RequestBody, &identity)
|
json.Unmarshal(u.Ctx.Input.RequestBody, &identity)
|
||||||
id := models.UpdateIdentity(&identity)
|
err := models.UpdateIdentity(&identity)
|
||||||
u.Data["json"] = id
|
if err != nil {
|
||||||
|
u.Data["json"] = err.Error()
|
||||||
|
} else {
|
||||||
|
u.Data["json"] = "ok"
|
||||||
|
}
|
||||||
u.ServeJSON()
|
u.ServeJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,16 +13,16 @@ type PeerController struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// @Title Create
|
// @Title Create
|
||||||
// @Description create peer
|
// @Description create peers
|
||||||
// @Param body body models.Peer true "The peer content"
|
// @Param body body []models.Peer true "The peer content"
|
||||||
// @Success 200 {string} models.Peer.Id
|
// @Success 200 {string} models.Peer.Id
|
||||||
// @Failure 403 body is empty
|
// @Failure 403 body is empty
|
||||||
// @router / [post]
|
// @router / [post]
|
||||||
func (o *PeerController) Post() {
|
func (o *PeerController) Post() {
|
||||||
var ob models.Peer
|
var ob []models.Peer
|
||||||
json.Unmarshal(o.Ctx.Input.RequestBody, &ob)
|
json.Unmarshal(o.Ctx.Input.RequestBody, &ob)
|
||||||
peerid := models.AddOne(ob)
|
models.AddPeers(ob)
|
||||||
o.Data["json"] = map[string]string{"PeerId": peerid}
|
o.Data["json"] = map[string]string{"Added": "OK"}
|
||||||
o.ServeJSON()
|
o.ServeJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,44 +34,30 @@ func (o *PeerController) Post() {
|
|||||||
// @router /:peerId [get]
|
// @router /:peerId [get]
|
||||||
func (o *PeerController) Get() {
|
func (o *PeerController) Get() {
|
||||||
peerId := o.Ctx.Input.Param(":peerId")
|
peerId := o.Ctx.Input.Param(":peerId")
|
||||||
if peerId != "" {
|
|
||||||
ob, err := models.GetOne(peerId)
|
peer, err := models.GetPeer(peerId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
o.Data["json"] = err.Error()
|
o.Data["json"] = err.Error()
|
||||||
} else {
|
} else {
|
||||||
o.Data["json"] = ob
|
o.Data["json"] = peer
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
o.ServeJSON()
|
o.ServeJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Title GetAll
|
// @Title Find
|
||||||
// @Description get all peers
|
// @Description find peers with query
|
||||||
// @Success 200
|
// @Param query path string true "the keywords you need"
|
||||||
// @router / [get]
|
// @Success 200 {peers} []models.Peer
|
||||||
func (o *PeerController) GetAll() {
|
// @Failure 403
|
||||||
obs := models.GetAll()
|
// @router /find/:query [get]
|
||||||
o.Data["json"] = obs
|
func (o *PeerController) Find() {
|
||||||
o.ServeJSON()
|
query := o.Ctx.Input.Param(":query")
|
||||||
}
|
peers, err := models.FindPeers(query)
|
||||||
|
|
||||||
// @Title Update
|
|
||||||
// @Description update the peer
|
|
||||||
// @Param peerId path string true "The peerid you want to update"
|
|
||||||
// @Param body body models.Peer true "The body"
|
|
||||||
// @Success 200 {peer} models.Peer
|
|
||||||
// @Failure 403 :peerId is empty
|
|
||||||
// @router /:peerId [put]
|
|
||||||
func (o *PeerController) Put() {
|
|
||||||
peerId := o.Ctx.Input.Param(":peerId")
|
|
||||||
var ob models.Peer
|
|
||||||
json.Unmarshal(o.Ctx.Input.RequestBody, &ob)
|
|
||||||
|
|
||||||
err := models.Update(peerId, ob.Score)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
o.Data["json"] = err.Error()
|
o.Data["json"] = err.Error()
|
||||||
} else {
|
} else {
|
||||||
o.Data["json"] = "update success!"
|
o.Data["json"] = peers
|
||||||
}
|
}
|
||||||
o.ServeJSON()
|
o.ServeJSON()
|
||||||
}
|
}
|
||||||
@@ -84,7 +70,11 @@ func (o *PeerController) Put() {
|
|||||||
// @router /:peerId [delete]
|
// @router /:peerId [delete]
|
||||||
func (o *PeerController) Delete() {
|
func (o *PeerController) Delete() {
|
||||||
peerId := o.Ctx.Input.Param(":peerId")
|
peerId := o.Ctx.Input.Param(":peerId")
|
||||||
models.Delete(peerId)
|
err := models.Delete(peerId)
|
||||||
|
if err != nil {
|
||||||
|
o.Data["json"] = err.Error()
|
||||||
|
} else {
|
||||||
o.Data["json"] = "delete success!"
|
o.Data["json"] = "delete success!"
|
||||||
|
}
|
||||||
o.ServeJSON()
|
o.ServeJSON()
|
||||||
}
|
}
|
||||||
|
|||||||
10
discovery.json
Normal file
10
discovery.json
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"port": 8080,
|
||||||
|
"redisurl":"localhost:6379",
|
||||||
|
"redispassword":"",
|
||||||
|
"zincurl":"http://localhost:4080",
|
||||||
|
"zinclogin":"admin",
|
||||||
|
"zincpassword":"admin",
|
||||||
|
"identityfile":"/app/identity.json",
|
||||||
|
"defaultpeers":"/app/peers.json"
|
||||||
|
}
|
||||||
10
docker-compose.yml
Normal file
10
docker-compose.yml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
version: '3.4'
|
||||||
|
|
||||||
|
services:
|
||||||
|
ocdiscovery:
|
||||||
|
image: 'ocdiscovery:latest'
|
||||||
|
ports:
|
||||||
|
- 8088:8080
|
||||||
|
container_name: ocdiscovery
|
||||||
|
|
||||||
|
|
||||||
10
docker_discovery.json
Normal file
10
docker_discovery.json
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"port": 8080,
|
||||||
|
"redisurl":"localhost:6379",
|
||||||
|
"redispassword":"",
|
||||||
|
"zincurl":"http://localhost:4080",
|
||||||
|
"zinclogin":"admin",
|
||||||
|
"zincpassword":"admin",
|
||||||
|
"identityfile":"/app/identity.json",
|
||||||
|
"defaultpeers":"/app/peers.json"
|
||||||
|
}
|
||||||
102
go.mod
102
go.mod
@@ -1,76 +1,64 @@
|
|||||||
module oc-discovery
|
module oc-discovery
|
||||||
|
|
||||||
go 1.19
|
go 1.22.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/beego/beego v1.12.11
|
cloud.o-forge.io/core/oc-lib v0.0.0-20240902132116-fba1608edb70
|
||||||
github.com/beego/beego/v2 v2.0.7
|
github.com/beego/beego v1.12.13
|
||||||
github.com/google/uuid v1.3.0
|
github.com/beego/beego/v2 v2.3.0
|
||||||
|
github.com/go-redis/redis v6.15.9+incompatible
|
||||||
|
github.com/goraz/onion v0.1.3
|
||||||
github.com/smartystreets/goconvey v1.7.2
|
github.com/smartystreets/goconvey v1.7.2
|
||||||
|
github.com/tidwall/gjson v1.17.3
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/astaxie/beego v1.12.3 // indirect
|
|
||||||
github.com/beego/bee/v2 v2.0.4 // indirect
|
|
||||||
github.com/beorn7/perks v1.0.1 // indirect
|
github.com/beorn7/perks v1.0.1 // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||||
github.com/cilium/ebpf v0.10.0 // indirect
|
github.com/gabriel-vasile/mimetype v1.4.5 // indirect
|
||||||
github.com/cosiner/argv v0.1.0 // indirect
|
github.com/go-playground/locales v0.14.1 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||||
github.com/derekparker/trie v0.0.0-20221221181808-1424fce0c981 // indirect
|
github.com/go-playground/validator/v10 v10.22.0 // indirect
|
||||||
github.com/flosch/pongo2 v0.0.0-20200913210552-0d938eb266f3 // indirect
|
github.com/golang/protobuf v1.5.4 // indirect
|
||||||
github.com/flosch/pongo2/v6 v6.0.0 // indirect
|
github.com/golang/snappy v0.0.4 // indirect
|
||||||
github.com/fsnotify/fsnotify v1.6.0 // indirect
|
github.com/google/uuid v1.6.0 // indirect
|
||||||
github.com/go-delve/delve v1.20.1 // indirect
|
|
||||||
github.com/go-delve/liner v1.2.3-0.20220127212407-d32d89dd2a5d // indirect
|
|
||||||
github.com/go-sql-driver/mysql v1.7.0 // indirect
|
|
||||||
github.com/golang/protobuf v1.5.2 // indirect
|
|
||||||
github.com/google/go-cmp v0.5.9 // indirect
|
|
||||||
github.com/google/go-dap v0.7.0 // indirect
|
|
||||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 // indirect
|
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 // indirect
|
||||||
github.com/gorilla/websocket v1.5.0 // indirect
|
github.com/hashicorp/golang-lru v1.0.2 // indirect
|
||||||
github.com/hashicorp/golang-lru v0.5.4 // indirect
|
|
||||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
|
||||||
github.com/jtolds/gls v4.20.0+incompatible // indirect
|
github.com/jtolds/gls v4.20.0+incompatible // indirect
|
||||||
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect
|
github.com/klauspost/compress v1.17.9 // indirect
|
||||||
github.com/kr/text v0.2.0 // indirect
|
github.com/kr/pretty v0.3.1 // indirect
|
||||||
github.com/lib/pq v1.10.7 // indirect
|
github.com/leodido/go-urn v1.4.0 // indirect
|
||||||
github.com/magiconair/properties v1.8.7 // indirect
|
|
||||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
github.com/mattn/go-runewidth v0.0.14 // indirect
|
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
|
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
|
||||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||||
github.com/pelletier/go-toml v1.9.5 // indirect
|
github.com/montanaflynn/stats v0.7.1 // indirect
|
||||||
github.com/pelletier/go-toml/v2 v2.0.7 // indirect
|
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||||
github.com/peterh/liner v1.2.2 // indirect
|
github.com/nats-io/nats.go v1.37.0 // indirect
|
||||||
|
github.com/nats-io/nkeys v0.4.7 // indirect
|
||||||
|
github.com/nats-io/nuid v1.0.1 // indirect
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
github.com/prometheus/client_golang v1.14.0 // indirect
|
github.com/prometheus/client_golang v1.20.2 // indirect
|
||||||
github.com/prometheus/client_model v0.3.0 // indirect
|
github.com/prometheus/client_model v0.6.1 // indirect
|
||||||
github.com/prometheus/common v0.41.0 // indirect
|
github.com/prometheus/common v0.57.0 // indirect
|
||||||
github.com/prometheus/procfs v0.9.0 // indirect
|
github.com/prometheus/procfs v0.15.1 // indirect
|
||||||
github.com/rivo/uniseg v0.4.4 // indirect
|
github.com/robfig/cron/v3 v3.0.1 // indirect
|
||||||
github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18 // indirect
|
github.com/rs/zerolog v1.33.0 // indirect
|
||||||
github.com/sirupsen/logrus v1.9.0 // indirect
|
github.com/shiena/ansicolor v0.0.0-20230509054315-a9deabde6e02 // indirect
|
||||||
github.com/smartwalle/pongo2render v1.0.2 // indirect
|
|
||||||
github.com/smartystreets/assertions v1.2.0 // indirect
|
github.com/smartystreets/assertions v1.2.0 // indirect
|
||||||
github.com/spf13/afero v1.9.5 // indirect
|
github.com/tidwall/match v1.1.1 // indirect
|
||||||
github.com/spf13/cast v1.5.0 // indirect
|
github.com/tidwall/pretty v1.2.1 // indirect
|
||||||
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
|
||||||
github.com/spf13/pflag v1.0.5 // indirect
|
github.com/xdg-go/scram v1.1.2 // indirect
|
||||||
github.com/spf13/viper v1.15.0 // indirect
|
github.com/xdg-go/stringprep v1.0.4 // indirect
|
||||||
github.com/stretchr/testify v1.8.1 // indirect
|
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
|
||||||
github.com/subosito/gotenv v1.4.2 // indirect
|
go.mongodb.org/mongo-driver v1.16.1 // indirect
|
||||||
go.starlark.net v0.0.0-20230302034142-4b1e35fe2254 // indirect
|
golang.org/x/crypto v0.26.0 // indirect
|
||||||
golang.org/x/arch v0.3.0 // indirect
|
golang.org/x/net v0.28.0 // indirect
|
||||||
golang.org/x/crypto v0.7.0 // indirect
|
golang.org/x/sync v0.8.0 // indirect
|
||||||
golang.org/x/mod v0.9.0 // indirect
|
golang.org/x/sys v0.24.0 // indirect
|
||||||
golang.org/x/net v0.8.0 // indirect
|
golang.org/x/text v0.17.0 // indirect
|
||||||
golang.org/x/sys v0.6.0 // indirect
|
google.golang.org/protobuf v1.34.2 // indirect
|
||||||
golang.org/x/text v0.8.0 // indirect
|
|
||||||
golang.org/x/tools v0.6.0 // indirect
|
|
||||||
google.golang.org/protobuf v1.28.1 // indirect
|
|
||||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
|
||||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
18
identity.json
Normal file
18
identity.json
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"name": "MyIdentity",
|
||||||
|
"private_key": "mykey",
|
||||||
|
"id": "1",
|
||||||
|
"public_attributes": {
|
||||||
|
"peer_id": "a50d3697-7ede-4fe5-a385-e9d01ebc1000",
|
||||||
|
"name": "IRT Saint Exupery",
|
||||||
|
"keywords": [
|
||||||
|
"algorithm",
|
||||||
|
"research",
|
||||||
|
"development",
|
||||||
|
"ai"
|
||||||
|
],
|
||||||
|
"last_seen_online": "2023-03-07T11:57:13.378707853+01:00",
|
||||||
|
"api_version": "1",
|
||||||
|
"api_url": "https://irt.irtse.com/oc"
|
||||||
|
}
|
||||||
|
}
|
||||||
36
main.go
36
main.go
@@ -1,18 +1,44 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"oc-discovery/models"
|
||||||
_ "oc-discovery/routers"
|
_ "oc-discovery/routers"
|
||||||
|
|
||||||
"github.com/beego/beego/logs"
|
oclib "cloud.o-forge.io/core/oc-lib"
|
||||||
|
"cloud.o-forge.io/core/oc-lib/logs"
|
||||||
|
"cloud.o-forge.io/core/oc-lib/tools"
|
||||||
beego "github.com/beego/beego/v2/server/web"
|
beego "github.com/beego/beego/v2/server/web"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const appname = "oc-discovery"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
log := logs.NewLogger(10000)
|
// Init the oc-lib
|
||||||
log.SetLogger("console")
|
oclib.Init(appname, "", "")
|
||||||
if beego.BConfig.RunMode == "dev" {
|
// get the right config file
|
||||||
|
|
||||||
|
o := tools.GetConfLoader()
|
||||||
|
|
||||||
|
models.GetConfig().Port = o.GetIntDefault("port", 8080)
|
||||||
|
models.GetConfig().LokiUrl = o.GetStringDefault("lokiurl", "")
|
||||||
|
models.GetConfig().RedisUrl = o.GetStringDefault("redisurl", "localhost:6379")
|
||||||
|
models.GetConfig().RedisPassword = o.GetStringDefault("redispassword", "")
|
||||||
|
models.GetConfig().ZincUrl = o.GetStringDefault("zincurl", "http://localhost:4080")
|
||||||
|
models.GetConfig().ZincLogin = o.GetStringDefault("zinclogin", "admin")
|
||||||
|
models.GetConfig().ZincPassword = o.GetStringDefault("zincpassword", "admin")
|
||||||
|
models.GetConfig().IdentityFile = o.GetStringDefault("identityfile", "./identity.json")
|
||||||
|
models.GetConfig().Defaultpeers = o.GetStringDefault("defaultpeers", "./peers.json")
|
||||||
|
|
||||||
|
// set oc-lib logger
|
||||||
|
if models.GetConfig().LokiUrl != "" {
|
||||||
|
logs.CreateLogger(appname, models.GetConfig().LokiUrl)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Normal beego init
|
||||||
|
beego.BConfig.AppName = appname
|
||||||
|
beego.BConfig.Listen.HTTPPort = models.GetConfig().Port
|
||||||
beego.BConfig.WebConfig.DirectoryIndex = true
|
beego.BConfig.WebConfig.DirectoryIndex = true
|
||||||
beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
|
beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
|
||||||
}
|
|
||||||
beego.Run()
|
beego.Run()
|
||||||
}
|
}
|
||||||
|
|||||||
25
models/config.go
Normal file
25
models/config.go
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
package models
|
||||||
|
|
||||||
|
import "sync"
|
||||||
|
|
||||||
|
type Config struct {
|
||||||
|
Port int
|
||||||
|
LokiUrl string
|
||||||
|
ZincUrl string
|
||||||
|
ZincLogin string
|
||||||
|
ZincPassword string
|
||||||
|
RedisUrl string
|
||||||
|
RedisPassword string
|
||||||
|
IdentityFile string
|
||||||
|
Defaultpeers string
|
||||||
|
}
|
||||||
|
|
||||||
|
var instance *Config
|
||||||
|
var once sync.Once
|
||||||
|
|
||||||
|
func GetConfig() *Config {
|
||||||
|
once.Do(func() {
|
||||||
|
instance = &Config{}
|
||||||
|
})
|
||||||
|
return instance
|
||||||
|
}
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/google/uuid"
|
"encoding/json"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/beego/beego/logs"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -9,21 +12,33 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Me = Identity{uuid.New().String(), "My name", "My key", "MyUrl"}
|
content, err := os.ReadFile("./identity.json")
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("Error when opening file: ", err)
|
||||||
|
}
|
||||||
|
err = json.Unmarshal(content, &Me)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("Error during Unmarshal(): ", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type Identity struct {
|
type Identity struct {
|
||||||
Id string
|
Id string `json:"id,omitempty"`
|
||||||
Name string
|
Name string `json:"name,omitempty"`
|
||||||
PublicKey string
|
PrivateKey string `json:"private_key,omitempty"`
|
||||||
Url string
|
PublicAttributes Peer `json:"public_attributes,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetIdentity() (u *Identity) {
|
func GetIdentity() (u *Identity) {
|
||||||
return &Me
|
return &Me
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpdateIdentity(uu *Identity) (a *Identity) {
|
func UpdateIdentity(uu *Identity) error {
|
||||||
Me = *uu
|
Me = *uu
|
||||||
return &Me
|
jsonBytes, err := json.Marshal(uu)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
os.WriteFile("./identity.json", jsonBytes, 0600)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,7 @@ package models
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"strconv"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/beego/beego/logs"
|
"github.com/beego/beego/logs"
|
||||||
@@ -12,20 +10,36 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
Peers []Peer
|
Peers []Peer
|
||||||
|
Store Storage
|
||||||
)
|
)
|
||||||
|
|
||||||
type Peer struct {
|
type Peer struct {
|
||||||
PeerId string `json:"peer_id,omitempty"`
|
PeerId string `json:"peer_id,omitempty"`
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
Score int64 `json:"score,omitempty"`
|
EntityName string `json:"entity_name,omitempty"`
|
||||||
|
EntityType string `json:"entity_type,omitempty"`
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
Website string `json:"website,omitempty"`
|
||||||
|
Address string `json:"address,omitempty"`
|
||||||
|
Postcode string `json:"postcode,omitempty"`
|
||||||
|
City string `json:"city,omitempty"`
|
||||||
|
Country string `json:"country,omitempty"`
|
||||||
|
Phone string `json:"phone,omitempty"`
|
||||||
|
Email string `json:"email,omitempty"`
|
||||||
|
Activity string `json:"activity,omitempty"`
|
||||||
Keywords []string `json:"keywords,omitempty"`
|
Keywords []string `json:"keywords,omitempty"`
|
||||||
|
ApiUrl string `json:"api_url,omitempty"`
|
||||||
|
PublicKey string `json:"public_key,omitempty"`
|
||||||
|
// internal use
|
||||||
|
Score int64 `json:"score,omitempty"`
|
||||||
LastSeenOnline time.Time `json:"last_seen_online,omitempty"`
|
LastSeenOnline time.Time `json:"last_seen_online,omitempty"`
|
||||||
ApiVersion string `json:"api_version,omitempty"`
|
ApiVersion string `json:"api_version,omitempty"`
|
||||||
Url string `json:"url,omitempty"`
|
|
||||||
PublicKey string `json:"public_key,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
c := GetConfig()
|
||||||
|
Store = Storage{c.ZincUrl, c.ZincLogin, c.ZincPassword, c.RedisUrl, c.RedisPassword}
|
||||||
|
Store = Storage{"http://localhost:4080", "admin", "admin", "localhost:6379", ""}
|
||||||
//p := Peer{uuid.New().String(), 0, []string{"car", "highway", "images", "video"}, time.Now(), "1", "asf", ""}
|
//p := Peer{uuid.New().String(), 0, []string{"car", "highway", "images", "video"}, time.Now(), "1", "asf", ""}
|
||||||
// pa := []Peer{p}
|
// pa := []Peer{p}
|
||||||
// byteArray, err := json.Marshal(pa)
|
// byteArray, err := json.Marshal(pa)
|
||||||
@@ -41,29 +55,34 @@ func init() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
logs.Error("Error during Unmarshal(): ", err)
|
logs.Error("Error during Unmarshal(): ", err)
|
||||||
}
|
}
|
||||||
|
Store.ImportData(LoadPeersJson("./peers.json"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddOne(peer Peer) (PeerId string) {
|
func AddPeers(peers []Peer) (status string) {
|
||||||
peer.PeerId = "astaxie" + strconv.FormatInt(time.Now().UnixNano(), 10)
|
err := Store.ImportData(peers)
|
||||||
Peers = append(Peers, peer)
|
if err != nil {
|
||||||
return peer.PeerId
|
logs.Error("Error during Unmarshal(): ", err)
|
||||||
|
return "error"
|
||||||
|
}
|
||||||
|
return "ok"
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetOne(PeerId string) (peer *Peer, err error) {
|
func FindPeers(query string) (peers []Peer, err error) {
|
||||||
|
result, err := Store.FindPeers(query)
|
||||||
return nil, errors.New("PeerId Not Exist")
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetAll() []Peer {
|
func GetPeer(uid string) (*Peer, error) {
|
||||||
return Peers
|
return Store.GetPeer(uid)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Update(PeerId string, Score int64) (err error) {
|
func Delete(PeerId string) error {
|
||||||
|
err := Store.DeletePeer(PeerId)
|
||||||
return errors.New("PeerId Not Exist")
|
if err != nil {
|
||||||
}
|
return err
|
||||||
|
}
|
||||||
func Delete(PeerId string) {
|
return nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
206
models/storage.go
Normal file
206
models/storage.go
Normal file
@@ -0,0 +1,206 @@
|
|||||||
|
package models
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/beego/beego/logs"
|
||||||
|
"github.com/go-redis/redis"
|
||||||
|
"github.com/tidwall/gjson"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Storage struct {
|
||||||
|
ZincUrl string
|
||||||
|
ZincLogin string
|
||||||
|
ZincPassword string
|
||||||
|
RedisUrl string
|
||||||
|
RedisPassword string
|
||||||
|
}
|
||||||
|
|
||||||
|
func LoadPeersJson(filename string) []Peer {
|
||||||
|
var peers []Peer
|
||||||
|
content, err := os.ReadFile("./peers.json")
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("Error when opening file: ", err)
|
||||||
|
}
|
||||||
|
err = json.Unmarshal(content, &peers)
|
||||||
|
if err != nil {
|
||||||
|
logs.Error("Error during Unmarshal(): ", err)
|
||||||
|
}
|
||||||
|
return peers
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Storage) ImportData(peers []Peer) error {
|
||||||
|
rdb := redis.NewClient(&redis.Options{
|
||||||
|
Addr: s.RedisUrl,
|
||||||
|
Password: s.RedisPassword, // no password set
|
||||||
|
DB: 0, // use default DB
|
||||||
|
})
|
||||||
|
var indexedPeers []map[string]interface{}
|
||||||
|
for _, p := range peers {
|
||||||
|
// Creating data block for indexing
|
||||||
|
indexedPeer := make(map[string]interface{})
|
||||||
|
indexedPeer["_id"] = p.PeerId
|
||||||
|
indexedPeer["name"] = p.Name
|
||||||
|
indexedPeer["keywords"] = p.Keywords
|
||||||
|
indexedPeer["name"] = p.Name
|
||||||
|
indexedPeer["entityname"] = p.EntityName
|
||||||
|
indexedPeer["entitytype"] = p.EntityType
|
||||||
|
indexedPeer["activity"] = p.Activity
|
||||||
|
indexedPeer["address"] = p.Address
|
||||||
|
indexedPeer["postcode"] = p.Postcode
|
||||||
|
indexedPeer["city"] = p.City
|
||||||
|
indexedPeer["country"] = p.Country
|
||||||
|
indexedPeer["description"] = p.Description
|
||||||
|
indexedPeer["apiurl"] = p.ApiUrl
|
||||||
|
indexedPeer["website"] = p.Website
|
||||||
|
indexedPeers = append(indexedPeers, indexedPeer)
|
||||||
|
// Adding peer to Redis (fast retieval and status updates)
|
||||||
|
jsonp, err := json.Marshal(p)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = rdb.Set("peer:"+p.PeerId, jsonp, 0).Err()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bulk := map[string]interface{}{"index": "peers", "records": indexedPeers}
|
||||||
|
raw, err := json.Marshal(bulk)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
req, err := http.NewRequest("POST", s.ZincUrl+"/api/_bulkv2", strings.NewReader(string(raw)))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
req.SetBasicAuth(s.ZincLogin, s.ZincPassword)
|
||||||
|
req.Header.Set("Content-Type", "application/json")
|
||||||
|
req.Header.Set("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36")
|
||||||
|
|
||||||
|
resp, err := http.DefaultClient.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
log.Println(resp.StatusCode)
|
||||||
|
body, err := io.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
fmt.Println(string(body))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Storage) FindPeers(queryString string) ([]Peer, error) {
|
||||||
|
var peers []Peer
|
||||||
|
query := `{
|
||||||
|
"search_type": "match",
|
||||||
|
"query":
|
||||||
|
{
|
||||||
|
"term": "` + queryString + `",
|
||||||
|
"start_time": "2020-06-02T14:28:31.894Z",
|
||||||
|
"end_time": "2029-12-02T15:28:31.894Z"
|
||||||
|
},
|
||||||
|
"from": 0,
|
||||||
|
"max_results": 100,
|
||||||
|
"_source": []
|
||||||
|
}`
|
||||||
|
req, err := http.NewRequest("POST", s.ZincUrl+"/api/peers/_search", strings.NewReader(query))
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
req.SetBasicAuth(s.ZincLogin, s.ZincPassword)
|
||||||
|
req.Header.Set("Content-Type", "application/json")
|
||||||
|
req.Header.Set("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36")
|
||||||
|
|
||||||
|
resp, err := http.DefaultClient.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
log.Println(resp.StatusCode)
|
||||||
|
body, err := io.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
value := gjson.Get(string(body), "hits.hits")
|
||||||
|
rdb := redis.NewClient(&redis.Options{
|
||||||
|
Addr: s.RedisUrl,
|
||||||
|
Password: s.RedisPassword, // no password set
|
||||||
|
DB: 0, // use default DB
|
||||||
|
})
|
||||||
|
for _, v := range value.Array() {
|
||||||
|
peerBytes, err := rdb.Get("peer:" + v.Get("_id").Str).Bytes()
|
||||||
|
if err != nil {
|
||||||
|
logs.Error(err)
|
||||||
|
} else {
|
||||||
|
var p Peer
|
||||||
|
err = json.Unmarshal(peerBytes, &p)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
peers = append(peers, p)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return peers, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Storage) GetPeer(uid string) (*Peer, error) {
|
||||||
|
var peer Peer
|
||||||
|
rdb := redis.NewClient(&redis.Options{
|
||||||
|
Addr: s.RedisUrl,
|
||||||
|
Password: s.RedisPassword, // no password set
|
||||||
|
DB: 0, // use default DB
|
||||||
|
})
|
||||||
|
peerBytes, err := rdb.Get("peer:" + uid).Bytes()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else {
|
||||||
|
err = json.Unmarshal(peerBytes, &peer)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &peer, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Storage) DeletePeer(uid string) error {
|
||||||
|
// Removing from Redis
|
||||||
|
rdb := redis.NewClient(&redis.Options{
|
||||||
|
Addr: s.RedisUrl,
|
||||||
|
Password: s.RedisPassword, // no password set
|
||||||
|
DB: 0, // use default DB
|
||||||
|
})
|
||||||
|
err := rdb.Unlink("peer:" + uid).Err()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// Removing from Index
|
||||||
|
req, err := http.NewRequest("DELETE", s.ZincUrl+"/api/peers/_doc"+uid, nil)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
req.SetBasicAuth(s.ZincLogin, s.ZincPassword)
|
||||||
|
req.Header.Set("Content-Type", "application/json")
|
||||||
|
req.Header.Set("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36")
|
||||||
|
|
||||||
|
resp, err := http.DefaultClient.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
log.Println(resp.StatusCode)
|
||||||
|
body, err := io.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
fmt.Println(string(body))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
BIN
oc-discovery
BIN
oc-discovery
Binary file not shown.
14
peers.json
14
peers.json
@@ -10,10 +10,10 @@
|
|||||||
],
|
],
|
||||||
"last_seen_online": "2023-03-07T11:57:13.378707853+01:00",
|
"last_seen_online": "2023-03-07T11:57:13.378707853+01:00",
|
||||||
"api_version": "1",
|
"api_version": "1",
|
||||||
"url": "https://asf.irtse.com/oc"
|
"api_url": "http://127.0.0.1:49618/v1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"peer_id": "a50d3697-7ede-4fe5-a385-e9d01ebc1002",
|
"peer_id": "a50d3697-7ede-4fe5-a385-e9d01ebc1003",
|
||||||
"name": "IT",
|
"name": "IT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"car",
|
"car",
|
||||||
@@ -23,10 +23,10 @@
|
|||||||
],
|
],
|
||||||
"last_seen_online": "2023-03-07T11:57:13.378707853+01:00",
|
"last_seen_online": "2023-03-07T11:57:13.378707853+01:00",
|
||||||
"api_version": "1",
|
"api_version": "1",
|
||||||
"url": "https://it.irtse.com/oc"
|
"api_url": "https://it.irtse.com/oc"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"peer_id": "a50d3697-7ede-4fe5-a385-e9d01ebc1002",
|
"peer_id": "a50d3697-7ede-4fe5-a385-e9d01ebc1004",
|
||||||
"name": "Centre de traitement des amendes",
|
"name": "Centre de traitement des amendes",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"car",
|
"car",
|
||||||
@@ -36,10 +36,10 @@
|
|||||||
],
|
],
|
||||||
"last_seen_online": "2023-03-07T11:57:13.378707853+01:00",
|
"last_seen_online": "2023-03-07T11:57:13.378707853+01:00",
|
||||||
"api_version": "1",
|
"api_version": "1",
|
||||||
"url": "https://impots.irtse.com/oc"
|
"api_url": "https://impots.irtse.com/oc"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"peer_id": "a50d3697-7ede-4fe5-a385-e9d01ebc1002",
|
"peer_id": "a50d3697-7ede-4fe5-a385-e9d01ebc1005",
|
||||||
"name": "Douanes",
|
"name": "Douanes",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"car",
|
"car",
|
||||||
@@ -49,6 +49,6 @@
|
|||||||
],
|
],
|
||||||
"last_seen_online": "2023-03-07T11:57:13.378707853+01:00",
|
"last_seen_online": "2023-03-07T11:57:13.378707853+01:00",
|
||||||
"api_version": "1",
|
"api_version": "1",
|
||||||
"url": "https://douanes.irtse.com/oc"
|
"api_url": "https://douanes.irtse.com/oc"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -34,15 +34,6 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["oc-discovery/controllers:PeerController"] = append(beego.GlobalControllerRouter["oc-discovery/controllers:PeerController"],
|
|
||||||
beego.ControllerComments{
|
|
||||||
Method: "GetAll",
|
|
||||||
Router: `/`,
|
|
||||||
AllowHTTPMethods: []string{"get"},
|
|
||||||
MethodParams: param.Make(),
|
|
||||||
Filters: nil,
|
|
||||||
Params: nil})
|
|
||||||
|
|
||||||
beego.GlobalControllerRouter["oc-discovery/controllers:PeerController"] = append(beego.GlobalControllerRouter["oc-discovery/controllers:PeerController"],
|
beego.GlobalControllerRouter["oc-discovery/controllers:PeerController"] = append(beego.GlobalControllerRouter["oc-discovery/controllers:PeerController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "Get",
|
Method: "Get",
|
||||||
@@ -54,18 +45,18 @@ func init() {
|
|||||||
|
|
||||||
beego.GlobalControllerRouter["oc-discovery/controllers:PeerController"] = append(beego.GlobalControllerRouter["oc-discovery/controllers:PeerController"],
|
beego.GlobalControllerRouter["oc-discovery/controllers:PeerController"] = append(beego.GlobalControllerRouter["oc-discovery/controllers:PeerController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "Put",
|
Method: "Delete",
|
||||||
Router: `/:peerId`,
|
Router: `/:peerId`,
|
||||||
AllowHTTPMethods: []string{"put"},
|
AllowHTTPMethods: []string{"delete"},
|
||||||
MethodParams: param.Make(),
|
MethodParams: param.Make(),
|
||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["oc-discovery/controllers:PeerController"] = append(beego.GlobalControllerRouter["oc-discovery/controllers:PeerController"],
|
beego.GlobalControllerRouter["oc-discovery/controllers:PeerController"] = append(beego.GlobalControllerRouter["oc-discovery/controllers:PeerController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "Delete",
|
Method: "Find",
|
||||||
Router: `/:peerId`,
|
Router: `/find/:query`,
|
||||||
AllowHTTPMethods: []string{"delete"},
|
AllowHTTPMethods: []string{"get"},
|
||||||
MethodParams: param.Make(),
|
MethodParams: param.Make(),
|
||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|||||||
Reference in New Issue
Block a user