Skip to content

Aggregation API server with custom or non resource URLs to serve static contents #131640

Open
@swathinsankaran

Description

@swathinsankaran

Hi All,

I am trying out a few things in the sample-apiserver app and added a few custom paths "/v3/hello" to serve static content, say a webpage, for my learning purposes. I was expecting the path to be present while doing a curl to the "/" path, but it is not present in the returned list.

I searched the internet and found a project, Antrea, which uses this, but couldn't make it work. I referred to https://github.com/antrea-io/antrea/blob/f707fa976cd4b3110bcd64bbf6eaf64f05c557f4/pkg/apiserver/apiserver.go#L296, which has a similar implementation.

I tried using the client below, but I got an error the server could not find the requested resource.

	restClient, err := rest.UnversionedRESTClientFor(config)
	if err != nil {
		panic(fmt.Errorf("failed to create rest client: %w", err))
	}

	u := url.URL{Path: "/v3/hello"}
	getter := restClient.Get().RequestURI(u.RequestURI()).Timeout(10*time.Second)
	result, err := getter.DoRaw(context.TODO())
	if err != nil {
		panic(err)		
	}
	fmt.Println(string(result))

The Aggregated API documentation does not seem to cover this topic, or I couldn't find it anywhere.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.sig/api-machineryCategorizes an issue or PR as relevant to SIG API Machinery.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions