Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Nicholas Bailey
rust-gitlab
Commits
212a6c46
Commit
212a6c46
authored
Oct 30, 2016
by
Ben Boeckel
⛰
Browse files
gitlab: simplify construction
parent
9cb1ba9b
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/gitlab.rs
View file @
212a6c46
...
...
@@ -57,21 +57,19 @@ impl Gitlab {
///
/// Errors out if `token` is invalid.
pub
fn
new
<
T
:
ToString
>
(
host
:
&
str
,
token
:
T
)
->
GitlabResult
<
Self
>
{
let
base_url
=
try
!
(
Url
::
parse
(
&
format!
(
"https://{}/api/v3/"
,
host
)));
Self
::
_new
(
host
,
token
.to_string
(),
base_url
)
Self
::
_new
(
"https"
,
host
,
token
.to_string
())
}
/// Create a new non-SSL Gitlab API representation.
///
/// Errors out if `token` is invalid.
pub
fn
new_insecure
<
T
:
ToString
>
(
host
:
&
str
,
token
:
T
)
->
GitlabResult
<
Self
>
{
let
base_url
=
try
!
(
Url
::
parse
(
&
format!
(
"http://{}/api/v3/"
,
host
)));
Self
::
_new
(
host
,
token
.to_string
(),
base_url
)
Self
::
_new
(
"http"
,
host
,
token
.to_string
())
}
fn
_new
(
host
:
&
str
,
token
:
String
,
base_url
:
Url
)
->
GitlabResult
<
Self
>
{
fn
_new
(
protocol
:
&
str
,
host
:
&
str
,
token
:
String
)
->
GitlabResult
<
Self
>
{
let
base_url
=
try
!
(
Url
::
parse
(
&
format!
(
"{}://{}/api/v3/"
,
protocol
,
host
)));
let
api
=
Gitlab
{
base_url
:
base_url
,
token
:
token
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment