package gowebdav12import (3"encoding/base64"4"net/http"5)67// BasicAuth structure holds our credentials8type BasicAuth struct {9user string10pw string11}1213// Type identifies the BasicAuthenticator14func (b *BasicAuth) Type() string {15return "BasicAuth"16}1718// User holds the BasicAuth username19func (b *BasicAuth) User() string {20return b.user21}2223// Pass holds the BasicAuth password24func (b *BasicAuth) Pass() string {25return b.pw26}2728// Authorize the current request29func (b *BasicAuth) Authorize(req *http.Request, method string, path string) {30a := b.user + ":" + b.pw31auth := "Basic " + base64.StdEncoding.EncodeToString([]byte(a))32req.Header.Set("Authorization", auth)33}343536