2021-04-08 09:54:47 +02:00
|
|
|
package rest
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
2021-04-11 09:50:27 +02:00
|
|
|
"net/url"
|
2021-04-08 09:54:47 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func BadRequest(w http.ResponseWriter) {
|
|
|
|
http.Error(w, "400 bad request", http.StatusBadRequest)
|
|
|
|
}
|
|
|
|
|
|
|
|
func Accept(w http.ResponseWriter) {
|
|
|
|
w.WriteHeader(202)
|
2021-04-09 12:40:37 +02:00
|
|
|
w.Write([]byte("Thanks, bro. Will process this soon, pinky swear!"))
|
2021-04-08 09:54:47 +02:00
|
|
|
}
|
2021-04-11 09:50:27 +02:00
|
|
|
|
|
|
|
// assumes the URL is well-formed.
|
|
|
|
func BaseUrlOf(link string) *url.URL {
|
|
|
|
obj, _ := url.Parse(link)
|
|
|
|
baseUrl, _ := url.Parse(obj.Scheme + "://" + obj.Host)
|
|
|
|
return baseUrl
|
|
|
|
}
|