Skip to content

Commit

Permalink
(feat) add delay option for /submit* endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
leonjza committed Sep 22, 2024
1 parent a9e254d commit 1db81b3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
4 changes: 4 additions & 0 deletions web/api/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type submitRequestOptions struct {
Y int `json:"window_y"`
UserAgent string `json:"user_agent"`
Timeout int `json:"timeout"`
Delay int `json:"delay"`
Format string `json:"format"`
}

Expand Down Expand Up @@ -64,6 +65,9 @@ func (h *ApiHandler) SubmitHandler(w http.ResponseWriter, r *http.Request) {
if request.Options.Timeout != 0 {
options.Scan.Timeout = request.Options.Timeout
}
if request.Options.Delay != 0 {
options.Scan.Delay = request.Options.Delay
}
if request.Options.Format != "" {
options.Scan.ScreenshotFormat = request.Options.Format
}
Expand Down
7 changes: 5 additions & 2 deletions web/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,9 @@ const docTemplate = `{
],
"responses": {
"200": {
"description": "Probing started",
"description": "The URL Result object",
"schema": {
"type": "string"
"$ref": "#/definitions/models.Result"
}
}
}
Expand Down Expand Up @@ -566,6 +566,9 @@ const docTemplate = `{
"api.submitRequestOptions": {
"type": "object",
"properties": {
"delay": {
"type": "integer"
},
"format": {
"type": "string"
},
Expand Down
7 changes: 5 additions & 2 deletions web/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,9 @@
],
"responses": {
"200": {
"description": "Probing started",
"description": "The URL Result object",
"schema": {
"type": "string"
"$ref": "#/definitions/models.Result"
}
}
}
Expand Down Expand Up @@ -555,6 +555,9 @@
"api.submitRequestOptions": {
"type": "object",
"properties": {
"delay": {
"type": "integer"
},
"format": {
"type": "string"
},
Expand Down
6 changes: 4 additions & 2 deletions web/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ definitions:
type: object
api.submitRequestOptions:
properties:
delay:
type: integer
format:
type: string
timeout:
Expand Down Expand Up @@ -560,9 +562,9 @@ paths:
- application/json
responses:
"200":
description: Probing started
description: The URL Result object
schema:
type: string
$ref: '#/definitions/models.Result'
summary: Submit a single URL for probing
tags:
- Results
Expand Down

0 comments on commit 1db81b3

Please sign in to comment.