Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
api
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bram Hagens
api
Commits
f860ea7f
Commit
f860ea7f
authored
5 years ago
by
Dean
Browse files
Options
Downloads
Patches
Plain Diff
add /upload/simple routes
parent
450e6e26
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.editorconfig
+10
-0
10 additions, 0 deletions
.editorconfig
lib/routes/uploadpomf.go
+12
-2
12 additions, 2 deletions
lib/routes/uploadpomf.go
main.go
+4
-2
4 additions, 2 deletions
main.go
with
26 additions
and
4 deletions
.editorconfig
0 → 100644
+
10
−
0
View file @
f860ea7f
root
=
true
[*]
end_of_line
=
lf
insert_final_newline
=
true
[*.go]
indent_style
=
tab
indent_size
=
8
tab_width
=
8
This diff is collapsed.
Click to expand it.
lib/routes/uploadpomf.go
+
12
−
2
View file @
f860ea7f
...
...
@@ -6,6 +6,7 @@ import (
"crypto/sha256"
"encoding/hex"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
...
...
@@ -76,7 +77,7 @@ type fileWebhookRequest struct {
}
// UploadPomf handles Pomf multipart/form-data upload requests.
func
UploadPomf
(
associateObjectsWithUser
bool
)
func
(
http
.
ResponseWriter
,
*
http
.
Request
)
{
func
UploadPomf
(
associateObjectsWithUser
bool
,
simpleResponse
bool
)
func
(
http
.
ResponseWriter
,
*
http
.
Request
)
{
return
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
// Only authorized users can use this route
user
:=
middleware
.
GetAuthorizedUser
(
r
)
...
...
@@ -351,6 +352,15 @@ func UploadPomf(associateObjectsWithUser bool) func(http.ResponseWriter, *http.R
// Return response
w
.
Header
()
.
Set
(
"Content-Type"
,
"application/json"
)
w
.
WriteHeader
(
statusCode
)
render
.
JSON
(
w
,
r
,
fullResponse
{
Success
:
true
,
Files
:
fileResponses
})
// Simple response
if
simpleResponse
{
for
_
,
fResponse
:=
range
fileResponses
{
w
.
Write
([]
byte
(
fmt
.
Sprintf
(
"%s
\n
"
,
fResponse
.
URL
)))
}
}
else
{
render
.
JSON
(
w
,
r
,
fullResponse
{
Success
:
true
,
Files
:
fileResponses
})
}
}
}
This diff is collapsed.
Click to expand it.
main.go
+
4
−
2
View file @
f860ea7f
...
...
@@ -174,8 +174,10 @@ func main() {
// Route handlers
r
.
Get
(
"/shorten/polr"
,
routes
.
ShortenPolr
(
false
))
r
.
Get
(
"/shorten/polr/associated"
,
routes
.
ShortenPolr
(
true
))
r
.
Post
(
"/upload/pomf"
,
routes
.
UploadPomf
(
false
))
r
.
Post
(
"/upload/pomf/associated"
,
routes
.
UploadPomf
(
true
))
r
.
Post
(
"/upload/pomf"
,
routes
.
UploadPomf
(
false
,
false
))
r
.
Post
(
"/upload/pomf/associated"
,
routes
.
UploadPomf
(
true
,
false
))
r
.
Post
(
"/upload/simple"
,
routes
.
UploadPomf
(
false
,
true
))
r
.
Post
(
"/upload/simple/associated"
,
routes
.
UploadPomf
(
true
,
true
))
r
.
Post
(
"/users"
,
routes
.
CreateUser
)
r
.
Get
(
"/users/me"
,
routes
.
Me
)
r
.
Get
(
"/objects"
,
routes
.
ListObjects
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment