package main

import (
	"net/http"
	"net/url"
)

type FWDAuth struct {
	URI *url.URL
}

func (f FWDAuth) checkAuth(username, password string) (res bool, err error) {
	if r, err := http.NewRequest("GET", f.URI.String(), nil); err != nil {
		return false, err
	} else {
		r.SetBasicAuth(username, password)

		if resp, err := http.DefaultClient.Do(r); err != nil {
			return false, err
		} else {
			resp.Body.Close()

			return resp.StatusCode < 400, err
		}
	}
}
