How to use @hapi/accept - 4 common examples

To help you get started, we’ve selected a few @hapi/accept examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github reworkjs / reworkjs / src / framework / server / setup-http-server / serve-react-route.js View on Github external
export default async function serveReactRoute(req: $Request, res: $Response, next: NextFunction): Promise {

  try {
    const serverHooks = ServerHooks.map(hookModule => {
      const HookClass = getDefault(hookModule);

      return new HookClass();
    });

    try {
      const acceptedLanguages = Object.freeze(accept.languages(req.header('Accept-Language')));
      const loadableResources = new Map();
      const persistentValues = new Map();

      let component = (
        
          
            {/* custom prop injected by universal-cookies */}
            {/* $FlowFixMe */}
            
              
                {rootRoute}
              
            
          
        
      );
github ybonnefond / stubborn / src / Router.ts View on Github external
function findAcceptTypes(headers: ResponseHeaders) {
  const headerKey = Object.keys(headers).find(name =>
    new RegExp('^accept$', 'i').test(name),
  );

  return 'undefined' === typeof headerKey
    ? []
    : accept.mediaTypes(headers[headerKey]);
}
/**
github hapijs / hapi / lib / compression.js View on Github external
internals.common.forEach((header) => {

            this._common.set(header, Accept.encoding(header, this.encodings));
        });
    }
github hapijs / hapi / lib / compression.js View on Github external
accept(request) {

        const header = request.headers['accept-encoding'];
        if (!header) {
            return 'identity';
        }

        const common = this._common.get(header);
        if (common) {
            return common;
        }

        try {
            return Accept.encoding(header, this.encodings);
        }
        catch (err) {
            Bounce.rethrow(err, 'system');
            err.header = header;
            request._log(['accept-encoding', 'error'], err);
            return 'identity';
        }
    }

@hapi/accept

HTTP Accept-* headers parsing

BSD-3-Clause
Latest version published 6 months ago

Package Health Score

84 / 100
Full package analysis