Temporary rest api that directly
inserts data into postgres of handle server
Golang v1.24.0
$ cd handle-server-api
$ go build
Live
$ cd handle-server-api
$ go run main.go server
Or after build
$ ./handle-server-api server
Runtime options can be set with the following environment variables.
-
HDL_PREFIXrequired prefix.
Required: true
Default: there is no default
-
HDL_HOSTHost to bind to
Default:
0.0.0.0 -
HDL_PORTPort to bind to
Default:
3000 -
HDL_DSNSQL DSN to the database of handle.net
Default:
handle:handle@tcp(127.0.0.1:5432)/handle?sslmode=disable -
HDL_AUTH_USERNAMEUsername for basic auth
Default:
handle -
HDL_AUTH_PASSWORDPassword for basic auth
Default:
handle
I've tried to be as close to the original API as possible.
See Technical Manual Version 9
All endpoint require basic http authentication.
See environment variable HDL_AUTH_USERNAME and HDL_AUTH_PASSWORD above
Retrieve all handle values of type URL
for handle {prefix}/{local_id}
Response:
{
"values" : [
{
"ttl" : 86400,
"type" : "URL",
"timestamp" : "2022-05-04T06:45:34Z",
"data" : {
"format" : "string",
"url" : "https://biblio.ugent.be/publication/1000117"
},
"index" : 1
}
],
"handle" : "1854/LU-1000117",
"responseCode" : 1
}
responseCode: 1 means "successfull"
responseCode: 100 means "not found"
but http status codes also help, although a 404
may also mean that you've hit the wrong controller
Delete all handle values for handle {prefix}/{local_id}
Insert/replace all handle value for handle {prefix}/{local_id}
Only body parameter url is supported
Returns same response as the GET controller
- Environment can also indirectly be set by placing a file called
.envin the current directory, and adding all environment variables (but WITHOUT keywordexport!).