-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(http): improve error handling and response to api consumer for or…
…g service
- Loading branch information
Showing
15 changed files
with
200 additions
and
422 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package http | ||
|
||
import ( | ||
"context" | ||
"net/url" | ||
|
||
"github.com/influxdata/httprouter" | ||
"github.com/influxdata/influxdb" | ||
) | ||
|
||
func decodeIDFromCtx(ctx context.Context, name string) (influxdb.ID, error) { | ||
params := httprouter.ParamsFromContext(ctx) | ||
idStr := params.ByName(name) | ||
|
||
if idStr == "" { | ||
return 0, &influxdb.Error{ | ||
Code: influxdb.EInvalid, | ||
Msg: "url missing " + name, | ||
} | ||
} | ||
|
||
var i influxdb.ID | ||
if err := i.DecodeFromString(idStr); err != nil { | ||
return 0, &influxdb.Error{ | ||
Code: influxdb.EInvalid, | ||
Err: err, | ||
} | ||
} | ||
|
||
return i, nil | ||
} | ||
|
||
func decodeIDFromQuery(v url.Values, key string) (influxdb.ID, error) { | ||
idStr := v.Get(key) | ||
if idStr == "" { | ||
return 0, nil | ||
} | ||
|
||
id, err := influxdb.IDFromString(idStr) | ||
if err != nil { | ||
return 0, &influxdb.Error{ | ||
Code: influxdb.EInvalid, | ||
Err: err, | ||
} | ||
} | ||
return *id, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.