@libp2p/http
    Preparing search index...

    Interface HandlerRoute<H>

    A simple route that defines a handler function

    interface HandlerRoute<H> {
        cors?: boolean;
        handler: H;
        method?: string | string[];
        path?: string;
    }

    Type Parameters

    • H

    Hierarchy (View Summary)

    Index

    Properties

    cors?: boolean

    By default all handlers support CORS headers, pass false here to disallow access to fetch requests.

    true
    
    handler: H
    method?: string | string[]

    A list of HTTP verbs this handler will respond to. If the handler is found but the request method is not present a 405 will be returned.

    ['GET']
    
    path?: string

    Specify a path to serve the protocol from. If omitted the protocol name will be used.

    Paths can be looked up from the protocol map using getProtocolMap() or by making a GET request to /.well-known/libp2p/protocols.