code: func NewIdpAuthnRequest(idp *IdentityProvider, r *http.Request) (*IdpAuthnRequest, error) {
  	req := &IdpAuthnRequest{
  		IDP:         idp,
  		HTTPRequest: r,
  	}
  
  	switch r.Method {
  	case "GET":
  		compressedRequest, err := base64.StdEncoding.DecodeString(r.URL.Query().Get("SAMLRequest"))
  		if err != nil {
  			return nil, fmt.Errorf("cannot decode request: %s", err)
  		}
  		req.RequestBuffer, err = ioutil.ReadAll(flate.NewReader(bytes.NewReader(compressedRequest)))
  		if err != nil {
  			return nil, fmt.Errorf("cannot decompress request: %s", err)
  		}
  		req.RelayState = r.URL.Query().Get("RelayState")
  	case "POST":
  		if err := r.ParseForm(); err != nil {
  			return nil, err
  		}
  		var err error
  		req.RequestBuffer, err = base64.StdEncoding.DecodeString(r.PostForm.Get("SAMLRequest"))
  		if err != nil {
  			return nil, err
  		}
  		req.RelayState = r.PostForm.Get("RelayState")
  	default:
  		return nil, fmt.Errorf("method not allowed")
  	}
  	return req, nil
  }
docs: // NewIdpAuthnRequest returns a new IdpAuthnRequest for the given HTTP request to the authorization
  // service.