You've already forked oauth2-proxy
mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2025-06-21 00:29:44 +02:00
Auth and standard logging with file rolling
This commit is contained in:
10
api/api.go
10
api/api.go
@ -4,22 +4,22 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/bitly/go-simplejson"
|
||||
"github.com/pusher/oauth2_proxy/logger"
|
||||
)
|
||||
|
||||
// Request parses the request body into a simplejson.Json object
|
||||
func Request(req *http.Request) (*simplejson.Json, error) {
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
if err != nil {
|
||||
log.Printf("%s %s %s", req.Method, req.URL, err)
|
||||
logger.Printf("%s %s %s", req.Method, req.URL, err)
|
||||
return nil, err
|
||||
}
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
resp.Body.Close()
|
||||
log.Printf("%d %s %s %s", resp.StatusCode, req.Method, req.URL, body)
|
||||
logger.Printf("%d %s %s %s", resp.StatusCode, req.Method, req.URL, body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -37,12 +37,12 @@ func Request(req *http.Request) (*simplejson.Json, error) {
|
||||
func RequestJSON(req *http.Request, v interface{}) error {
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
if err != nil {
|
||||
log.Printf("%s %s %s", req.Method, req.URL, err)
|
||||
logger.Printf("%s %s %s", req.Method, req.URL, err)
|
||||
return err
|
||||
}
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
resp.Body.Close()
|
||||
log.Printf("%d %s %s %s", resp.StatusCode, req.Method, req.URL, body)
|
||||
logger.Printf("%d %s %s %s", resp.StatusCode, req.Method, req.URL, body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user