// parseLinkHeader is an incomplete parser for RFC8288 compliant header fields.
// It makes heavy assumptions around how GitLab uses web linking for keyset pagination.
// See https://docs.gitlab.com/ee/api/projects.html#list-all-projects for more info.
parseLinkHeader is an incomplete parser for RFC8288 compliant header fields.
It makes heavy assumptions around how GitLab uses web linking for keyset pagination.
// parseLinkHeader is an incomplete parser for RFC8288 compliant header fields . // It makes heavy assumptions around how GitLab uses web linking for keyset pagination . // See https : // docs . gitlab . com / ee / api / projects . html#list - all - projects for more info .
func parseLinkHeader(header string) (linkHeader, error) {
	var lh linkHeader
	elems := strings.Split(header, ";")
	if !strings.HasPrefix(elems[0], "<") {
		return linkHeader{}, &ParseError{Err: ErrNoRFC5988LinkHeader, Header: header}
	}
	lh.link = elems[0][1 : len(elems[0])-1]
	_, err := url.Parse(lh.link)
	if err != nil {
		return linkHeader{}, &ParseError{Err: err, Header: header}
	}
	if !strings.HasPrefix(strings.TrimSpace(elems[1]), "rel") {
		return linkHeader{}, &ParseError{Err: ErrNoRFC5988LinkHeader, Header: header}
	}
	trimmedRel := strings.TrimPrefix(strings.TrimSpace(elems[1]), "rel=")
	lh.rel = trimmedRel[1 : len(trimmedRel)-1]
	return lh, nil
}
func parseLinkHeader ( header string ) ( linkHeader , error ) { var lh linkHeader elems := strings . Split ( header , " " ) if ! strings . HasPrefix ( elems [ 0 ] , " " ) { return linkHeader { } , & ParseError { Err : ErrNoRFC5988LinkHeader , Header : header } } lh . link = elems [ 0 ] [ 1 : len ( elems [ 0 ] ) - 1 ] _ , err := url . Parse ( lh . link ) if err != nil { return linkHeader { } , & ParseError { Err : err , Header : header } } if ! strings . HasPrefix ( strings . TrimSpace ( elems [ 1 ] ) , " " ) { return linkHeader { } , & ParseError { Err : ErrNoRFC5988LinkHeader , Header : header } } trimmedRel := strings . TrimPrefix ( strings . TrimSpace ( elems [ 1 ] ) , " " ) lh . rel = trimmedRel [ 1 : len ( trimmedRel ) - 1 ] return lh , nil }
parseLinkHeader is an incomplete parser for RFC8288 compliant header fields.
parseLinkHeader is an incomplete parser for RFC8288 compliant header fields .