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
package strategy | |
import ( | |
"io" | |
"net/http" | |
"net/http/httputil" | |
"os" | |
"github.com/julienschmidt/httprouter" | |
) |
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
package strategy | |
import ( | |
"net/http" | |
"net/http/httputil" | |
"github.com/julienschmidt/httprouter" | |
) | |
func FwdOptionsReq(rp *httputil.ReverseProxy) httprouter.Handle{ |
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
package Router | |
import ( | |
"fmt" | |
"net/http/httputil" | |
"github.com/julienschmidt/httprouter" | |
s "github.com/lautarojayat/auth_proxy/proxy/strategy" | |
) |
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
package director | |
import ( | |
"net/http" | |
"os" | |
) | |
func NewDirector() func(req *http.Request){ | |
host:= os.Getenv("HOST") |
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
package main | |
import ( | |
"fmt" | |
"net/http" | |
"net/http/httputil" | |
"os" | |
d "github.com/lautarojayat/auth_proxy/proxy/director" |
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
package main | |
import ( | |
"fmt" | |
"io" | |
"net/http" | |
"os" | |
) | |
func welcome(w http.ResponseWriter, r *http.Request) { |
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
ctrl.forVideo = function (req, res) { | |
// First we store our file name in a variable using a inmediatly-invoked function | |
let file = (function () { | |
// Split the URL in each slash "/"; | |
let splitted = req.url.split('/'); | |
// Then we return only the last part of that array. | |
return splitted[splitted.length - 1]; | |
})(); | |
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
const ctrl = require('./controllers/controllers'); | |
const app = (req, res) => { | |
const URL = req.url; | |
// What we say when the request method isnt GET | |
if (req.method !== 'GET') { | |
ctrl.forInvalidMethod(req, res); | |
} |
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
let array = [1, 2, 3, '4', undefined, 'a', [], null]; | |
function onlyNumbers(arr) { | |
let output = []; | |
// Now we try to parseInt() each element, | |
// and push a new Number() created with e as an argument. | |
arr.forEach(e => { if (parseInt(e)) { output.push(Number(e)) } }) | |
return output | |
} | |
console.log(onlyNumbers(array)); |
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
let array = [1, 2, 3, '4', undefined, 'a', [], null]; | |
function onlyNumbers(arr) { | |
let output = []; | |
// If 'isNaN()' doesn't return true for the given element, we pushit to the output array | |
arr.forEach(e => { if (!isNaN((e))) { output.push((e)) } }) | |
return output | |
} | |
console.log(onlyNumbers(array)); |
NewerOlder